Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Jul 11, 2023

Conversation

dashpole
Copy link
Contributor

@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
Copy link
Contributor 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

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
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?

sdk/metric/internal/aggregate/sum_test.go Outdated Show resolved Hide resolved
@dashpole
Copy link
Contributor 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
Contributor 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
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
Contributor 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
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