Skip to content

Commit

Permalink
Fix UnknownDataPointSnapshot constructor (#977)
Browse files Browse the repository at this point in the history
Signed-off-by: Mickael Maison <mickael.maison@gmail.com>
  • Loading branch information
mimaison authored Jul 30, 2024
1 parent 594a9de commit d567081
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static final class UnknownDataPointSnapshot extends DataPointSnapshot {
* @param exemplar may be null.
*/
public UnknownDataPointSnapshot(double value, Labels labels, Exemplar exemplar) {
this(value, Labels.EMPTY, exemplar, 0);
this(value, labels, exemplar, 0);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,20 @@ public void testNameMissing() {
public void testValueMissing() {
UnknownSnapshot.UnknownDataPointSnapshot.builder().build();
}

@Test
public void testUnknownDataPointSnapshot() {
Labels labels = Labels.of("k1", "v1");
Exemplar exemplar = Exemplar.builder().value(2.0).build();

UnknownSnapshot.UnknownDataPointSnapshot data = new UnknownSnapshot.UnknownDataPointSnapshot(1.0, labels, exemplar);
Assert.assertEquals(1.0, data.getValue(), 0.1);
Assert.assertEquals(labels, data.getLabels());
Assert.assertEquals(exemplar, data.getExemplar());

data = new UnknownSnapshot.UnknownDataPointSnapshot(1.0, labels, exemplar, 0L);
Assert.assertEquals(1.0, data.getValue(), 0.1);
Assert.assertEquals(labels, data.getLabels());
Assert.assertEquals(exemplar, data.getExemplar());
}
}

0 comments on commit d567081

Please sign in to comment.