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

Fix callback registration bug #4888

Merged
merged 2 commits into from
Feb 7, 2024
Merged

Conversation

MrAlias
Copy link
Contributor

@MrAlias MrAlias commented Feb 6, 2024

Fix #4884

Currently, the registration loop uses the loop variable in the anonymous function registered as a callback. This means all of these functions will reference the last callback in the iterated slice.

This fixes that issue by declaring a copy of the loop variable within the iteration scope.

Register all callbacks not just the last passed.
@MrAlias MrAlias modified the milestone: v1.24.0 Feb 6, 2024
@MrAlias MrAlias added bug Something isn't working area:metrics Part of OpenTelemetry Metrics labels Feb 6, 2024
@MrAlias MrAlias marked this pull request as ready for review February 6, 2024 20:01
@dashpole
Copy link
Contributor

dashpole commented Feb 6, 2024

This seems pretty serious. Should we consider a patch release?

@MrAlias
Copy link
Contributor Author

MrAlias commented Feb 6, 2024

This seems pretty serious. Should we consider a patch release?

I was thinking so.

Copy link

codecov bot commented Feb 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e3eb3f7) 0.0% compared to head (98a5c63) 82.6%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           main   #4888      +/-   ##
=======================================
+ Coverage      0   82.6%   +82.6%     
=======================================
  Files         0     232     +232     
  Lines         0   18870   +18870     
=======================================
+ Hits          0   15605   +15605     
- Misses        0    2975    +2975     
- Partials      0     290     +290     
Files Coverage Δ
sdk/metric/meter.go 90.5% <100.0%> (ø)

... and 231 files with indirect coverage changes

@MrAlias MrAlias merged commit 11ebd19 into open-telemetry:main Feb 7, 2024
29 checks passed
@MrAlias MrAlias deleted the fix-4884 branch February 7, 2024 20:00
@MrAlias MrAlias mentioned this pull request Feb 7, 2024
@XSAM XSAM added this to the Old Untracked PRs milestone Nov 7, 2024
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 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Only last registered callback is called from observable instrument
5 participants