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

[sdk-metrics] Fix a race condition when a metric is deactivated and re-activated in the same collection cycle #5908

Merged

Conversation

CodeBlanch
Copy link
Member

Fixes #5907

Changes

  • Use TryUpdate instead of TryRemove when processing a removed metric so that the lookup dictionary is only modified if a new metric hasn't already been enrolled

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)

@CodeBlanch CodeBlanch requested a review from a team as a code owner October 17, 2024 20:34
@github-actions github-actions bot added the pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package label Oct 17, 2024
Copy link

codecov bot commented Oct 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.41%. Comparing base (6250307) to head (201943f).
Report is 357 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5908      +/-   ##
==========================================
+ Coverage   83.38%   86.41%   +3.03%     
==========================================
  Files         297      258      -39     
  Lines       12531    11345    -1186     
==========================================
- Hits        10449     9804     -645     
+ Misses       2082     1541     -541     
Flag Coverage Δ
unittests ?
unittests-Project-Experimental 86.39% <100.00%> (?)
unittests-Project-Stable 86.35% <100.00%> (?)

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

Files with missing lines Coverage Δ
...rc/OpenTelemetry/Metrics/Reader/MetricReaderExt.cs 92.24% <100.00%> (ø)

... and 236 files with indirect coverage changes

Copy link
Contributor

@Kielek Kielek left a comment

Choose a reason for hiding this comment

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

LGTM.

Do you think that it is worth to document in CHANGE:LOG?

@CodeBlanch
Copy link
Member Author

@Kielek I don't think we need to mention anything in CHANGELOG because there really isn't any impact to users if they run into the race. Metrics will continue to work even if the wrong lookup entry is removed.

@CodeBlanch CodeBlanch merged commit 25a9366 into open-telemetry:main Oct 21, 2024
39 checks passed
@CodeBlanch CodeBlanch deleted the sdk-metrics-activation-race branch October 21, 2024 21:40
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.

[bug] MetricReaderExt.RemoveMetric is failing in certain unit tests
4 participants