Repository navigation
fix(metrics): assign start_time_unix_nano for Gauge metrics in SDK and encoders (#5849) - #5852
Open
ImamWahyudiz wants to merge 2 commits into
Open
ImamWahyudiz wants to merge 2 commits into
ImamWahyudiz wants to merge 2 commits into
Conversation
|
|
Pull request dashboard statusWaiting on reviewers · refreshed 2026-10-30 02:20 UTC Review the latest changes. Status above doesn't look right?
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: sdk/metrics: assign and encode start_time_unix_nano for Gauge (#5849)
Description
Per the MetricReader specification and Start timestamps specification,
StartTimeUnixNanorules apply to all metrics according to theMetricReader's configured temporality for the instrument kind, "not just those whose point kinds includes an aggregation temporality field."Prior to this PR,
GaugeandObservableGauge(LastValueaggregation) omittedstart_time_unix_nano:_LastValueAggregation.__init__omittedstart_time_unix_nano.DefaultAggregation._create_aggregation()andLastValueAggregation._create_aggregation()did not forwardstart_time_unix_nanoto_LastValueAggregation._LastValueAggregation.collect()explicitly assignedstart_time_unix_nano=Nonewhen creatingNumberDataPoint.proto/common/_internal/metrics_encoder/__init__.py) and OTLP JSON encoder (json/common/_internal/metrics_encoder/__init__.py) omittedstart_time_unix_nano=data_point.start_time_unix_nanowhen instantiatingpb2.NumberDataPointandJSONNumberDataPointfor Gauge metrics.Solution
opentelemetry-sdk:_LastValueAggregation.__init__to accept and storestart_time_unix_nano: int = 0.DefaultAggregation._create_aggregation()andLastValueAggregation._create_aggregation()to passstart_time_unix_nanointo_LastValueAggregation._LastValueAggregation.collect()to assignstart_time_unix_nano=self._start_time_unix_nanotoNumberDataPoint.opentelemetry-exporter-otlp-proto-common:start_time_unix_nano=data_point.start_time_unix_nanowhen instantiatingpb2.NumberDataPointfor Gauge metrics in_encode_metric().opentelemetry-exporter-otlp-json-common:start_time_unix_nano=data_point.start_time_unix_nanoin_encode_gauge_data_point().test_aggregation.pyto assertstart_time_unix_nano.test_encode_gauge_with_start_timeintest_metrics_encoder.pyfor Protobuf encoding.make_gauge()in JSON encoder tests and assertedstart_time_unix_nanointest_encode_gauge..changelog/5849.fixed.Type of Change
Testing & Verification
Checklist
ruff check,ruff format)..changelog/5849.fixed.