diff --git a/ffwd-client/src/test/java/com/spotify/ffwd/v1/MetricTest.java b/ffwd-client/src/test/java/com/spotify/ffwd/v1/MetricTest.java index 3c26204..1b4ab70 100644 --- a/ffwd-client/src/test/java/com/spotify/ffwd/v1/MetricTest.java +++ b/ffwd-client/src/test/java/com/spotify/ffwd/v1/MetricTest.java @@ -24,13 +24,14 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; - import com.google.protobuf.ByteString; import com.google.protobuf.InvalidProtocolBufferException; import com.spotify.ffwd.protocol1.Protocol1; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; -import java.util.List; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.Map; import org.junit.jupiter.api.Test; @@ -105,9 +106,10 @@ public void testSerializeDistributionValue() throws InvalidProtocolBufferExcepti private Metric createMetric(Value value, long time){ final long has = 1L; - return new Metric(has, time,KEY, - value, HOST, List.of(TAG1,TAG2 - ), Map.of(KEY,KEYVALUE) ); + final Map attributes = Collections.singletonMap(KEY, KEYVALUE); + return new Metric(has, time,KEY, + value, HOST, new ArrayList<>(Arrays.asList(TAG1,TAG2)), + attributes); } private double extractValue(Metric metric){ diff --git a/opencensus-exporter/src/main/java/com/spotify/ffwd/FfwdMetricsConverter.java b/opencensus-exporter/src/main/java/com/spotify/ffwd/FfwdMetricsConverter.java index 1084f8a..b98c51b 100644 --- a/opencensus-exporter/src/main/java/com/spotify/ffwd/FfwdMetricsConverter.java +++ b/opencensus-exporter/src/main/java/com/spotify/ffwd/FfwdMetricsConverter.java @@ -21,6 +21,7 @@ package com.spotify.ffwd; import com.google.common.base.Strings; +import com.google.common.collect.ImmutableList; import io.opencensus.common.Function; import io.opencensus.common.Functions; import io.opencensus.exporter.metrics.util.MetricExporter; @@ -37,6 +38,7 @@ import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -67,7 +69,8 @@ protected FfwdMetricsConverter(final FastForward client) { new Function>() { @Override public List apply(Double value) { - return List.of(new com.spotify.ffwd.Metric().value(value)); + return + Collections.singletonList(new com.spotify.ffwd.Metric().value(value)); } }; @@ -75,7 +78,8 @@ public List apply(Double value) { new Function>() { @Override public List apply(Long value) { - return List.of(new com.spotify.ffwd.Metric().value(value)); + return + Collections.singletonList(new com.spotify.ffwd.Metric().value(value)); } }; @@ -85,7 +89,7 @@ public List apply(Long value) { @Override public List apply(Distribution distribution) { //TODO: Big task of support distributions in Heroic. - return List.of(); + return new ArrayList<>(ImmutableList.of()); } }; private static final Function> typedValueSummaryFunction = @@ -97,7 +101,7 @@ public List apply(Summary summary) { summary.getSnapshot().getValueAtPercentiles(); // TODO: Add stat: min/max/average/p75/p99 - return List.of( + return Collections.singletonList( new com.spotify.ffwd.Metric().value(snapshot.get(50).getValue()) ); } diff --git a/opencensus-exporter/src/test/java/com/spotify/ffwd/FfwdMetricsConverterTest.java b/opencensus-exporter/src/test/java/com/spotify/ffwd/FfwdMetricsConverterTest.java index 7a72717..e4af727 100644 --- a/opencensus-exporter/src/test/java/com/spotify/ffwd/FfwdMetricsConverterTest.java +++ b/opencensus-exporter/src/test/java/com/spotify/ffwd/FfwdMetricsConverterTest.java @@ -32,6 +32,7 @@ import io.opencensus.metrics.export.TimeSeries; import io.opencensus.metrics.export.Value; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.Map; import org.junit.jupiter.api.BeforeEach; @@ -62,16 +63,16 @@ void counterisSent() throws IOException { Mockito.doNothing().when(client).send(metricCaptor.capture()); converter.export( - List.of( + Collections.singletonList( Metric.createWithOneTimeSeries( MetricDescriptor.create( "rps-requests", "requests", "requests", MetricDescriptor.Type.CUMULATIVE_DOUBLE, - List.of(LabelKey.create("status-code", "rpc status code"))), + Collections.singletonList(LabelKey.create("status-code", "rpc status code"))), TimeSeries.createWithOnePoint( - List.of(LabelValue.create("200")), + Collections.singletonList(LabelValue.create("200")), Point.create(Value.doubleValue(10.0), Timestamp.create(1575323125, 0)), Timestamp.create(1575323125, 0))))); @@ -84,8 +85,9 @@ void counterisSent() throws IOException { @Test void createTags() { - final List keys = List.of(LabelKey.create("status-code", "rpc status code")); - final List values = List.of(LabelValue.create("200")); + final List keys = + Collections.singletonList(LabelKey.create("status-code", "rpc status code")); + final List values = Collections.singletonList(LabelValue.create("200")); final Map tags = FfwdMetricsConverter.createTags(keys, values); @@ -94,8 +96,9 @@ void createTags() { @Test void createTagsSkipMissingValue() { - final List keys = List.of(LabelKey.create("status-code", "rpc status code")); - final List values = List.of(); + final List keys = + Collections.singletonList(LabelKey.create("status-code", "rpc status code")); + final List values = Collections.emptyList(); final Map tags = FfwdMetricsConverter.createTags(keys, values); diff --git a/pom.xml b/pom.xml index 6477650..b4fffd7 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ UTF-8 - 11 + 8 5.5.2 0.24.0 1.2