@Test public void testValidGraphiteMetricQueryResult() throws Exception { Instant fixedInstant = Instant.parse("2020-03-01T05:05:39Z"); MetricQueryService metricQueryService = new MetricQueryService(httpClient); MetricData metricDataResult = metricQueryService.queryMetricSource(metricSourceSinkConfig, metricFunctionsSpec, fixedInstant); assertEquals(12.0, metricDataResult.getValue(), 0.1); assertEquals(1583039100, metricDataResult.getTimestamp()); Map<String, String> tags = metricDataResult.getMetricDefinition().getTags().getKv(); assertEquals(6, tags.size()); assertEquals("sample_app1", tags.get("app_name")); assertEquals("test", tags.get("env")); assertEquals("custom_tag_value", tags.get("custom_tag")); assertEquals("sum", tags.get("aggregatedBy")); assertEquals("sumSeries(a.b.c)", tags.get("name")); assertEquals("added_tag_value", tags.get("added_tag")); }
public MetricData queryMetricSource(Config metricSourceSinkConfig, MetricFunctionsSpec metricFunctionsSpec, Instant instant) throws IllegalStateException, MetricQueryServiceException { String metricSourceName = metricSourceSinkConfig.getString(METRIC_SOURCE_KEY); switch (metricSourceName) { case "graphite": return queryGraphite(metricSourceSinkConfig, metricFunctionsSpec, instant); default: throw new IllegalStateException(String.format("Unknown metric source '%s'.", metricSourceName)); } }
MetricQueryService { public MetricData queryMetricSource(Config metricSourceSinkConfig, MetricFunctionsSpec metricFunctionsSpec, Instant instant) throws IllegalStateException, MetricQueryServiceException { String metricSourceName = metricSourceSinkConfig.getString(METRIC_SOURCE_KEY); switch (metricSourceName) { case "graphite": return queryGraphite(metricSourceSinkConfig, metricFunctionsSpec, instant); default: throw new IllegalStateException(String.format("Unknown metric source '%s'.", metricSourceName)); } } }
MetricQueryService { public MetricData queryMetricSource(Config metricSourceSinkConfig, MetricFunctionsSpec metricFunctionsSpec, Instant instant) throws IllegalStateException, MetricQueryServiceException { String metricSourceName = metricSourceSinkConfig.getString(METRIC_SOURCE_KEY); switch (metricSourceName) { case "graphite": return queryGraphite(metricSourceSinkConfig, metricFunctionsSpec, instant); default: throw new IllegalStateException(String.format("Unknown metric source '%s'.", metricSourceName)); } } MetricQueryService();  MetricQueryService(HttpClientWrapper httpClientWrapper); }
MetricQueryService { public MetricData queryMetricSource(Config metricSourceSinkConfig, MetricFunctionsSpec metricFunctionsSpec, Instant instant) throws IllegalStateException, MetricQueryServiceException { String metricSourceName = metricSourceSinkConfig.getString(METRIC_SOURCE_KEY); switch (metricSourceName) { case "graphite": return queryGraphite(metricSourceSinkConfig, metricFunctionsSpec, instant); default: throw new IllegalStateException(String.format("Unknown metric source '%s'.", metricSourceName)); } } MetricQueryService();  MetricQueryService(HttpClientWrapper httpClientWrapper); MetricData queryMetricSource(Config metricSourceSinkConfig, MetricFunctionsSpec metricFunctionsSpec,
            Instant instant); }
MetricQueryService { public MetricData queryMetricSource(Config metricSourceSinkConfig, MetricFunctionsSpec metricFunctionsSpec, Instant instant) throws IllegalStateException, MetricQueryServiceException { String metricSourceName = metricSourceSinkConfig.getString(METRIC_SOURCE_KEY); switch (metricSourceName) { case "graphite": return queryGraphite(metricSourceSinkConfig, metricFunctionsSpec, instant); default: throw new IllegalStateException(String.format("Unknown metric source '%s'.", metricSourceName)); } } MetricQueryService();  MetricQueryService(HttpClientWrapper httpClientWrapper); MetricData queryMetricSource(Config metricSourceSinkConfig, MetricFunctionsSpec metricFunctionsSpec,
            Instant instant);  }