Skip to content

Commit

Permalink
Merge branch '1.11.x' into 1.12.x
Browse files Browse the repository at this point in the history
  • Loading branch information
shakuzen committed May 8, 2024
2 parents 7623a0d + a9c08d8 commit 0de9dcd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ Metric writeGauge(Gauge gauge) {
return getMetricBuilder(gauge.getId())
.setGauge(io.opentelemetry.proto.metrics.v1.Gauge.newBuilder()
.addDataPoints(NumberDataPoint.newBuilder()
.setTimeUnixNano(getTimeUnixNano())
.setTimeUnixNano(TimeUnit.MILLISECONDS.toNanos(clock.wallTime()))
.setAsDouble(gauge.value())
.addAllAttributes(getTagsForId(gauge.getId()))
.build()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ void gauge() {
Metric metric = writeToMetric(gauge);
assertThat(metric.getGauge()).isNotNull();
assertThat(metric.getGauge().getDataPoints(0).getAsDouble()).isEqualTo(5);
assertThat(metric.getGauge().getDataPoints(0).getTimeUnixNano()).isEqualTo(TimeUnit.MINUTES.toNanos(1));
assertThat(metric.getGauge().getDataPoints(0).getTimeUnixNano())
.describedAs("Gauges should have timestamp of the instant when data is sampled")
.isEqualTo(otlpConfig().step().plus(Duration.ofMillis(1)).toNanos());
}

@Test
Expand All @@ -88,7 +90,9 @@ void timeGauge() {
Metric metric = writeToMetric(timeGauge);
assertThat(metric.getGauge()).isNotNull();
assertThat(metric.getGauge().getDataPoints(0).getAsDouble()).isEqualTo(0.024);
assertThat(metric.getGauge().getDataPoints(0).getTimeUnixNano()).isEqualTo(TimeUnit.MINUTES.toNanos(1));
assertThat(metric.getGauge().getDataPoints(0).getTimeUnixNano())
.describedAs("Gauges should have timestamp of the instant when data is sampled")
.isEqualTo(otlpConfig().step().plus(Duration.ofMillis(1)).toNanos());
}

@Test
Expand Down

0 comments on commit 0de9dcd

Please sign in to comment.