Skip to content

Commit

Permalink
Make project build Java 8 compatible artifacts (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmuhlha authored Nov 18, 2020
1 parent 1a827ee commit a14e8a4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
12 changes: 7 additions & 5 deletions ffwd-client/src/test/java/com/spotify/ffwd/v1/MetricTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<String, String> 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){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -67,15 +69,17 @@ protected FfwdMetricsConverter(final FastForward client) {
new Function<Double, List<com.spotify.ffwd.Metric>>() {
@Override
public List<com.spotify.ffwd.Metric> apply(Double value) {
return List.of(new com.spotify.ffwd.Metric().value(value));
return
Collections.singletonList(new com.spotify.ffwd.Metric().value(value));
}
};

private static final Function<Long, List<com.spotify.ffwd.Metric>> typedValueLongFunction =
new Function<Long, List<com.spotify.ffwd.Metric>>() {
@Override
public List<com.spotify.ffwd.Metric> apply(Long value) {
return List.of(new com.spotify.ffwd.Metric().value(value));
return
Collections.singletonList(new com.spotify.ffwd.Metric().value(value));
}
};

Expand All @@ -85,7 +89,7 @@ public List<com.spotify.ffwd.Metric> apply(Long value) {
@Override
public List<com.spotify.ffwd.Metric> apply(Distribution distribution) {
//TODO: Big task of support distributions in Heroic.
return List.of();
return new ArrayList<>(ImmutableList.of());
}
};
private static final Function<Summary, List<com.spotify.ffwd.Metric>> typedValueSummaryFunction =
Expand All @@ -97,7 +101,7 @@ public List<com.spotify.ffwd.Metric> 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())
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)))));

Expand All @@ -84,8 +85,9 @@ void counterisSent() throws IOException {

@Test
void createTags() {
final List<LabelKey> keys = List.of(LabelKey.create("status-code", "rpc status code"));
final List<LabelValue> values = List.of(LabelValue.create("200"));
final List<LabelKey> keys =
Collections.singletonList(LabelKey.create("status-code", "rpc status code"));
final List<LabelValue> values = Collections.singletonList(LabelValue.create("200"));

final Map<String, String> tags = FfwdMetricsConverter.createTags(keys, values);

Expand All @@ -94,8 +96,9 @@ void createTags() {

@Test
void createTagsSkipMissingValue() {
final List<LabelKey> keys = List.of(LabelKey.create("status-code", "rpc status code"));
final List<LabelValue> values = List.of();
final List<LabelKey> keys =
Collections.singletonList(LabelKey.create("status-code", "rpc status code"));
final List<LabelValue> values = Collections.emptyList();

final Map<String, String> tags = FfwdMetricsConverter.createTags(keys, values);

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.release>8</maven.compiler.release>
<junit-jupiter.version>5.5.2</junit-jupiter.version>
<opencensus.version>0.24.0</opencensus.version>
<auto.value.version>1.2</auto.value.version>
Expand Down

0 comments on commit a14e8a4

Please sign in to comment.