Skip to content

Conversation

@EliaSaSe
Copy link

@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: EliaSaSe / name: Elia Seikritt (ddc1a41)

@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
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 87.25%. Comparing base (6180ae3) to head (ddc1a41).
⚠️ 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   87.22%   87.25%   +0.02%     
==========================================
  Files         263      263              
  Lines       12385    12410      +25     
==========================================
+ Hits        10803    10828      +25     
  Misses       1582     1582              
Flag Coverage Δ
unittests-Project-Experimental 86.97% <100.00%> (-0.04%) ⬇️
unittests-Project-Stable 86.88% <100.00%> (-0.27%) ⬇️

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 85.75% <100.00%> (+0.11%) ⬆️
...c/OpenTelemetry/Metrics/MetricPoint/MetricPoint.cs 94.76% <100.00%> (+0.05%) ⬆️
src/OpenTelemetry/Metrics/MetricStreamIdentity.cs 90.97% <100.00%> (+1.28%) ⬆️

... and 3 files with indirect coverage changes

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

2 participants