Skip to content

Commit

Permalink
Json fix (#102)
Browse files Browse the repository at this point in the history
* add an id field to each MetricSetPair
* copy the id from the MetricSetPair to the analysis result
  • Loading branch information
Michael Graff committed Oct 16, 2017
1 parent 7512fd9 commit bedfcfb
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public class CanaryAnalysisResult {
@Getter
private Map<String, String> tags;

@NotNull
@Getter
private String id;

@NotNull
@Getter
private String classification;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@

import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -68,6 +65,7 @@ public MetricSetPair mixOne(MetricSet controlMetricSet, MetricSet experimentMetr
MetricSetPair.MetricSetPairBuilder metricSetPairBuilder =
MetricSetPair.builder()
.name(controlMetricSet.getName())
.id(UUID.randomUUID().toString())
.tags(controlMetricSet.getTags())
.value("control", controlValues)
.value("experiment", experimentValues);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public class MetricSetPair {
@Getter
private String name;

@NotNull
@Getter
private String id;

@NotNull
@Singular
@Getter
Expand All @@ -46,9 +50,11 @@ public class MetricSetPair {
private Map<String, List<Double>> values;

public MetricSetPair(String name,
String id,
Map<String, String> tags,
Map<String, List<Double>> values) {
this.name = name;
this.id = id;
this.tags = tags;
this.values = values;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,17 @@ class MetricSetMixerServiceSpec extends Specification {
metricSetPair.tags == [tagName: "tagValue"]
}

void "Mixing sets should produce an id field"() {
setup:
MetricSetMixerService metricSetMixerService = new MetricSetMixerService()

when:
MetricSetPair metricSetPair = metricSetMixerService.mixOne(controlCpuMetricSet, experimentCpuMetricSet)

then:
!metricSetPair.id.empty
}

void "missing values should be backfilled with trailing NaNs"() {
setup:
MetricSetMixerService metricSetMixerService = new MetricSetMixerService()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class NetflixACAJudge extends CanaryJudge with StrictLogging {

CanaryAnalysisResult.builder()
.name(metric.getName)
.id(metric.getId)
.tags(metric.getTags)
.classification(metricClassification.classification.toString)
.classificationReason(metricClassification.reason.orNull)
Expand Down

0 comments on commit bedfcfb

Please sign in to comment.