Skip to content

Fix: Observable instruments should not export stale series (#5950)#6883

Merged
rajkumar-rangaraj merged 19 commits intoopen-telemetry:mainfrom
EliaSaSe:observable-bug-5952
Feb 27, 2026
Merged

Fix: Observable instruments should not export stale series (#5950)#6883
rajkumar-rangaraj merged 19 commits intoopen-telemetry:mainfrom
EliaSaSe:observable-bug-5952

Conversation

@EliaSaSe
Copy link
Contributor

@EliaSaSe EliaSaSe commented Feb 9, 2026

Aims to Fix #5950.

Changes

The https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricreader requires that for asynchronous instruments, MetricReader.Collect MUST only receive data points with measurements recorded since the previous collection. The SDK was instead re-exporting the last known value indefinitely when an observable callback stopped reporting a series.

I seems, the delta temporality path does not have this issue, because of its metric point reclaim mechanism. This PR changes the cumulative path by:

  • Adding MetricStreamIdentity.IsAsynchronous to identify observable instruments (ObservableCounter, ObservableUpDownCounter, ObservableGauge)
  • In SnapshotCumulative, skipping metric points not reported in the current callback cycle
  • In MetricPoint.TakeSnapshot, resetting status to NoCollectPending after snapshot for asynchronous cumulative sum types, so unreported points are detected as stale in the next collection

No public API changes. But I'm not sure if the behavior change is considered as API change.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@EliaSaSe EliaSaSe requested a review from a team as a code owner February 9, 2026 20:39
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 9, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: rajkumar-rangaraj / name: Rajkumar Rangaraj (931fc1d)

@github-actions github-actions bot added the pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package label Feb 9, 2026
…metry#5950)

   Per the OpenTelemetry spec, MetricReader.Collect MUST only receive data
   points with measurements recorded since the previous collection for
   asynchronous instruments. The SDK was re-exporting the last known value
   indefinitely when an observable callback stopped reporting a series.

   Fixes open-telemetry#5950
@EliaSaSe EliaSaSe force-pushed the observable-bug-5952 branch from e5624bf to ddc1a41 Compare February 9, 2026 20:39
@EliaSaSe
Copy link
Contributor Author

EliaSaSe commented Feb 9, 2026

Hello @cijothomas, can You have a look at this PR to fix issue #5950? I tried make the most minimal code change. But I do not know the codebase enough to determine if this is a real fix or a hack. Should the MetricPointStatus be used for that? Have a nice day, Elia

@cijothomas
Copy link
Member

@EliaSaSe I triggered CI runs, so we'll know if this fixes the issue without other regression. Once this is done, we can ask maintainers to review the change. (I'll review as well, but will be few days before I can commit time.)

@codecov
Copy link

codecov bot commented Feb 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.53%. Comparing base (06f9384) to head (931fc1d).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6883      +/-   ##
==========================================
+ Coverage   88.51%   88.53%   +0.01%     
==========================================
  Files         263      263              
  Lines       12383    12408      +25     
==========================================
+ Hits        10961    10985      +24     
- Misses       1422     1423       +1     
Flag Coverage Δ
unittests-Project-Experimental 88.22% <100.00%> (-0.25%) ⬇️
unittests-Project-Stable 88.31% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/OpenTelemetry/Metrics/AggregatorStore.cs 87.59% <100.00%> (+0.09%) ⬆️
...c/OpenTelemetry/Metrics/MetricPoint/MetricPoint.cs 94.76% <100.00%> (+0.05%) ⬆️
src/OpenTelemetry/Metrics/MetricStreamIdentity.cs 91.66% <100.00%> (+1.19%) ⬆️

... and 3 files with indirect coverage changes

Copy link
Member

@rajkumar-rangaraj rajkumar-rangaraj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a minor test suggestion

@cijothomas
Copy link
Member

open-telemetry/opentelemetry-specification#4861 consider adding a test for this issue. I don't know the actual recommendation from spec yet, but lets have a test and confirm and document the current behavior.

@cijothomas
Copy link
Member

open-telemetry/opentelemetry-specification#4861 consider adding a test for this issue. I don't know the actual recommendation from spec yet, but lets have a test and confirm and document the current behavior.

open-telemetry/opentelemetry-rust#3334 you can steal this test case!

@EliaSaSe
Copy link
Contributor Author

Thanks for the feedbacks, it's appreciated. I will look into it as soon as I can, it may take a few days.

@EliaSaSe
Copy link
Contributor Author

open-telemetry/opentelemetry-specification#4861 consider adding a test for this issue. I don't know the actual recommendation from spec yet, but lets have a test and confirm and document the current behavior.

open-telemetry/opentelemetry-rust#3334 you can steal this test case!

I will look into it in the next few days.

@Kielek Kielek enabled auto-merge February 18, 2026 17:40
auto-merge was automatically disabled February 19, 2026 09:26

Head branch was pushed to by a user without write access

@Kielek Kielek requested a review from cijothomas February 19, 2026 09:30
@EliaSaSe
Copy link
Contributor Author

@martincostello One of the builds failed, but because it was cancelled. Can the failed one be retriggered? I consider the code change as done if cjiothomas does not request further changes.

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@rajkumar-rangaraj rajkumar-rangaraj added this pull request to the merge queue Feb 27, 2026
Merged via the queue into open-telemetry:main with commit 5889c91 Feb 27, 2026
63 checks passed
@github-actions
Copy link
Contributor

Thank you for your contribution @EliaSaSe! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

@EliaSaSe
Copy link
Contributor Author

Thank you all so much for your support. You made it easy to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature request] Add option to remove metric series that are no longer present in observable measurements

5 participants