Skip to content

Metric SDK: Do not export non-observed attribute sets for async instruments#4290

Merged
MrAlias merged 3 commits into
open-telemetry:mainfrom
dashpole:omit_nonobserved
Jul 11, 2023
Merged

Metric SDK: Do not export non-observed attribute sets for async instruments#4290
MrAlias merged 3 commits into
open-telemetry:mainfrom
dashpole:omit_nonobserved

Conversation

@dashpole
Copy link
Copy Markdown
Collaborator

@dashpole dashpole commented Jul 7, 2023

Fixes #3605
It addresses this issue by calling delete(s.values, attr) in precomputed aggregators for the value of an attribute set when it is sent. This ensures a given observation is only exported if it is recorded in that collection cycle.

For a simple example of the impact, see the diff in sdk/metric/meter_test.go.

@dashpole dashpole force-pushed the omit_nonobserved branch from 5fdb1d3 to 271d230 Compare July 7, 2023 20:50
@dashpole
Copy link
Copy Markdown
Collaborator Author

dashpole commented Jul 7, 2023

Additionally, for delta async instruments, omitting an attribute set from a callback in one call makes the next call assume that it is starting over from zero, rather than the previously recorded value

@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 7, 2023

Codecov Report

Merging #4290 (62b6e0e) into main (8b7bffc) will decrease coverage by 0.1%.
The diff coverage is 100.0%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #4290     +/-   ##
=======================================
- Coverage   83.5%   83.5%   -0.1%     
=======================================
  Files        183     183             
  Lines      14218   14217      -1     
=======================================
- Hits       11886   11881      -5     
- Misses      2105    2109      +4     
  Partials     227     227             
Impacted Files Coverage Δ
sdk/metric/meter.go 85.9% <ø> (ø)
sdk/metric/internal/aggregate/sum.go 100.0% <100.0%> (ø)

... and 1 file with indirect coverage changes

Copy link
Copy Markdown
Contributor

@MrAlias MrAlias left a comment

Choose a reason for hiding this comment

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

Looks good overall, just small questions.

Where do we plan to document the introduced behavior here and our recommendation to use these types of instruments for this feature? opentelemetry.io?

Comment thread sdk/metric/internal/aggregate/sum_test.go Outdated
@dashpole
Copy link
Copy Markdown
Collaborator Author

Where do we plan to document the introduced behavior here and our recommendation to use these types of instruments for this feature? opentelemetry.io?

I'm happy to document it here for now. If we can make sure this behavior is consistent across languages, then I think opentelemetry.io would be great.

@dashpole
Copy link
Copy Markdown
Collaborator Author

Would the SDK instrumentation constructors be an appropriate place to document the behavior? e.g. https://github.com/open-telemetry/opentelemetry-go/blob/main/sdk/metric/meter.go#L110

@MrAlias
Copy link
Copy Markdown
Contributor

MrAlias commented Jul 10, 2023

Would the SDK instrumentation constructors be an appropriate place to document the behavior? e.g. https://github.com/open-telemetry/opentelemetry-go/blob/main/sdk/metric/meter.go#L110

I think there and the RegisterCallback would be good places 👍

@dashpole
Copy link
Copy Markdown
Collaborator Author

I think there and the RegisterCallback would be good places 👍

Done

@MrAlias MrAlias merged commit de26aaa into open-telemetry:main Jul 11, 2023
@MrAlias MrAlias added this to the Metric SDK v0.40.0 milestone Aug 3, 2023
@MrAlias MrAlias added the area:metrics Part of OpenTelemetry Metrics label Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:metrics Part of OpenTelemetry Metrics

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

Support recording metrics with "churning" labels without "leaking" memory.

4 participants