Conversation
This was referenced Jul 8, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR addresses a race condition in the live metrics telemetry collector by introducing a read–write lock around the core counter operations.
- Adds a
ReadWriteLockto synchronizegetAndRestart,peek, and per-itemaddlogic. - Refactors helper methods to accept a
Countersinstance rather than fetching it internally. - Introduces early type and null checks to skip locking when no counters are available or for unsupported telemetry.
Comments suppressed due to low confidence (2)
sdk/monitor/azure-monitor-opentelemetry-autoconfigure/src/main/java/com/azure/monitor/opentelemetry/autoconfigure/implementation/quickpulse/QuickPulseDataCollector.java:62
- [nitpick] The field name
lockis very generic; consider renaming it to something likecountersLockorrwCountersLockto clarify its purpose.
private final ReadWriteLock lock = new ReentrantReadWriteLock();
sdk/monitor/azure-monitor-opentelemetry-autoconfigure/src/main/java/com/azure/monitor/opentelemetry/autoconfigure/implementation/quickpulse/QuickPulseDataCollector.java:94
- This method still uses
synchronizedinstead of the newReadWriteLock, causing mixed locking strategies that could lead to deadlock. Consider switching it tolock.readLock().lock()/unlock()or removing the synchronized keyword entirely.
synchronized QuickPulseStatus getQuickPulseStatus() {
...e/monitor/opentelemetry/autoconfigure/implementation/quickpulse/QuickPulseDataCollector.java
Show resolved
Hide resolved
...e/monitor/opentelemetry/autoconfigure/implementation/quickpulse/QuickPulseDataCollector.java
Show resolved
Hide resolved
harsimar
reviewed
Jul 14, 2025
...e/monitor/opentelemetry/autoconfigure/implementation/quickpulse/QuickPulseDataCollector.java
Show resolved
Hide resolved
xiang17
approved these changes
Jul 14, 2025
harsimar
approved these changes
Jul 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.