@Test public void test_inline_template_and_extended_scope_params_supplied() { String customInlineTemplate = "data('request.count', filter=" + "filter('server_group', 'my_microservice-control-v1'))" + ".mean(by=['${some_key}']).publish()"; SignalFxCanaryScope scope = new SignalFxCanaryScope(); CanaryConfig canaryConfig = CanaryConfig.builder().build(); SignalFxCanaryMetricSetQueryConfig metricSetQueryConfig = SignalFxCanaryMetricSetQueryConfig.builder() .customInlineTemplate(customInlineTemplate) .build(); CanaryScope canaryScope = CanaryScope.builder().build(); canaryScope.setExtendedScopeParams(ImmutableMap.of("some_key", "some_value")); SignalFxScopeConfiguration scopeConfiguration = SignalFxScopeConfiguration.builder().build(); String expected = "data('request.count', filter=" + "filter('server_group', 'my_microservice-control-v1'))" + ".mean(by=['some_value']).publish()"; assertEquals( expected, signalFxQueryBuilderService.buildQuery( canaryConfig, metricSetQueryConfig, canaryScope, scopeConfiguration, scope)); }
public String buildQuery( CanaryConfig canaryConfig, SignalFxCanaryMetricSetQueryConfig queryConfig, CanaryScope canaryScope, SignalFxScopeConfiguration scopeConfiguration, SignalFxCanaryScope signalFxCanaryScope) { String aggregationMethod = Optional.ofNullable(queryConfig.getAggregationMethod()).orElse("mean"); List<QueryPair> queryPairs = Optional.ofNullable(queryConfig.getQueryPairs()).orElse(new LinkedList<>()); String[] baseScopeAttributes = new String[] {"scope", "location"}; try { String customFilter = QueryConfigUtils.expandCustomFilter( canaryConfig, queryConfig, canaryScope, baseScopeAttributes); return Optional.ofNullable(customFilter) .orElseGet( () -> getSimpleProgram( queryConfig, scopeConfiguration, signalFxCanaryScope, aggregationMethod, queryPairs)); } catch (Exception e) { throw new RuntimeException("Failed to generate SignalFx SignalFlow program", e); } }
SignalFxQueryBuilderService { public String buildQuery( CanaryConfig canaryConfig, SignalFxCanaryMetricSetQueryConfig queryConfig, CanaryScope canaryScope, SignalFxScopeConfiguration scopeConfiguration, SignalFxCanaryScope signalFxCanaryScope) { String aggregationMethod = Optional.ofNullable(queryConfig.getAggregationMethod()).orElse("mean"); List<QueryPair> queryPairs = Optional.ofNullable(queryConfig.getQueryPairs()).orElse(new LinkedList<>()); String[] baseScopeAttributes = new String[] {"scope", "location"}; try { String customFilter = QueryConfigUtils.expandCustomFilter( canaryConfig, queryConfig, canaryScope, baseScopeAttributes); return Optional.ofNullable(customFilter) .orElseGet( () -> getSimpleProgram( queryConfig, scopeConfiguration, signalFxCanaryScope, aggregationMethod, queryPairs)); } catch (Exception e) { throw new RuntimeException("Failed to generate SignalFx SignalFlow program", e); } } }
SignalFxQueryBuilderService { public String buildQuery( CanaryConfig canaryConfig, SignalFxCanaryMetricSetQueryConfig queryConfig, CanaryScope canaryScope, SignalFxScopeConfiguration scopeConfiguration, SignalFxCanaryScope signalFxCanaryScope) { String aggregationMethod = Optional.ofNullable(queryConfig.getAggregationMethod()).orElse("mean"); List<QueryPair> queryPairs = Optional.ofNullable(queryConfig.getQueryPairs()).orElse(new LinkedList<>()); String[] baseScopeAttributes = new String[] {"scope", "location"}; try { String customFilter = QueryConfigUtils.expandCustomFilter( canaryConfig, queryConfig, canaryScope, baseScopeAttributes); return Optional.ofNullable(customFilter) .orElseGet( () -> getSimpleProgram( queryConfig, scopeConfiguration, signalFxCanaryScope, aggregationMethod, queryPairs)); } catch (Exception e) { throw new RuntimeException("Failed to generate SignalFx SignalFlow program", e); } }  }
SignalFxQueryBuilderService { public String buildQuery( CanaryConfig canaryConfig, SignalFxCanaryMetricSetQueryConfig queryConfig, CanaryScope canaryScope, SignalFxScopeConfiguration scopeConfiguration, SignalFxCanaryScope signalFxCanaryScope) { String aggregationMethod = Optional.ofNullable(queryConfig.getAggregationMethod()).orElse("mean"); List<QueryPair> queryPairs = Optional.ofNullable(queryConfig.getQueryPairs()).orElse(new LinkedList<>()); String[] baseScopeAttributes = new String[] {"scope", "location"}; try { String customFilter = QueryConfigUtils.expandCustomFilter( canaryConfig, queryConfig, canaryScope, baseScopeAttributes); return Optional.ofNullable(customFilter) .orElseGet( () -> getSimpleProgram( queryConfig, scopeConfiguration, signalFxCanaryScope, aggregationMethod, queryPairs)); } catch (Exception e) { throw new RuntimeException("Failed to generate SignalFx SignalFlow program", e); } }  String buildQuery(
      CanaryConfig canaryConfig,
      SignalFxCanaryMetricSetQueryConfig queryConfig,
      CanaryScope canaryScope,
      SignalFxScopeConfiguration scopeConfiguration,
      SignalFxCanaryScope signalFxCanaryScope); }
SignalFxQueryBuilderService { public String buildQuery( CanaryConfig canaryConfig, SignalFxCanaryMetricSetQueryConfig queryConfig, CanaryScope canaryScope, SignalFxScopeConfiguration scopeConfiguration, SignalFxCanaryScope signalFxCanaryScope) { String aggregationMethod = Optional.ofNullable(queryConfig.getAggregationMethod()).orElse("mean"); List<QueryPair> queryPairs = Optional.ofNullable(queryConfig.getQueryPairs()).orElse(new LinkedList<>()); String[] baseScopeAttributes = new String[] {"scope", "location"}; try { String customFilter = QueryConfigUtils.expandCustomFilter( canaryConfig, queryConfig, canaryScope, baseScopeAttributes); return Optional.ofNullable(customFilter) .orElseGet( () -> getSimpleProgram( queryConfig, scopeConfiguration, signalFxCanaryScope, aggregationMethod, queryPairs)); } catch (Exception e) { throw new RuntimeException("Failed to generate SignalFx SignalFlow program", e); } }  String buildQuery(
      CanaryConfig canaryConfig,
      SignalFxCanaryMetricSetQueryConfig queryConfig,
      CanaryScope canaryScope,
      SignalFxScopeConfiguration scopeConfiguration,
      SignalFxCanaryScope signalFxCanaryScope);  }