From 5b4abb5b57f5fa3eb8e32e1952ef60665609969c Mon Sep 17 00:00:00 2001 From: David Ashpole Date: Wed, 19 Jun 2024 06:13:04 -0400 Subject: [PATCH] Fix timestamp handling for the lastvalue aggregation (#5517) Fixes https://github.com/open-telemetry/opentelemetry-go/issues/5510 From https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricreader: > The ending timestamp (i.e. TimeUnixNano) MUST always be equal to time the metric data point took effect, which is equal to when [MetricReader.Collect](https://opentelemetry.io/docs/specs/otel/metrics/sdk/#collect) was invoked. These rules apply to all metrics, not just those whose [point kinds](https://opentelemetry.io/docs/specs/otel/metrics/data-model/#point-kinds) includes an aggregation temporality field. Before https://github.com/open-telemetry/opentelemetry-go/pull/5305, we used the measurement time as the timestamp, but it didn't matter because the collection time is always the same as the measurement time for asynchronous instruments. We didn't catch the issue when we implemented synchronous instruments. This PR changes the (end) timestamp handling for the Last Value aggregation to match the (end) timestamp handling for sum and histogram aggregations. As described in the spec above, we take the timestamp when computing the aggregation during Collect. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe611d8e00c..16fbc134a01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Run the `Detect` method in `go.opentelemetry.io/otel/sdk/resource` in parallel. (#5402) - Fix panic in baggage creation when a member contains 0x80 char in key or value. (#5494) - Correct comments for the priority of the `WithEndpoint` and `WithEndpointURL` options and their coresponding environment variables in in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc`. (#5508) +- Fix stale timestamps reported by the lastvalue aggregation. (#5517) ## [1.27.0/0.49.0/0.3.0] 2024-05-21