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

Update instrumentation with more call sites and instrumentation clearing endpoint #698

Merged
merged 4 commits into from
Jan 19, 2024

Conversation

akang31
Copy link
Contributor

@akang31 akang31 commented Jan 17, 2024

The instrumentation currently is missing a few cases that are addressed here:

  • OverrideProperties were not instrumented
  • Calls through getStringArray (which for NetflixConfiguration came via the getString call on for both DynamicProperty wrappers [updateValue] and direct NetflixConfiguration calls, covering a large portion of calls [basically anything not calling getProperty])

We also add the ability to clear used instrumentation to avoid repeatedly sending the same instrumentation data over the course of an application's lifetime.

@akang31 akang31 changed the title Add instrumentation on more call sites Update instrumentation with more call sites and instrumentation clearing endpoint Jan 17, 2024
}

public Set<String> getAndClearUsedProperties() {
synchronized (usedProperties) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Synchronizing on the map won't keep it from being modified concurrently by other threads, so there still a race condition where threadA calls getUsedProperties, threadB records a new usage, threadA clears the map, and now threadB's usage is lost.
The only way to avoid that would be to synchronize all methods that record access, in addition to this one. Not sure that'd be worth the performance hit, but in that case you might as well change the map back to a regular HashMap, instead of paying the ConcurrentHashMap tax.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Per offline discussion, updated this to use an AtomicReference instead

}

public Set<String> getAndClearUsedProperties() {
Set<String> ret = usedPropertiesRef.getAndSet(ConcurrentHashMap.newKeySet());
return Collections.unmodifiableSet(new HashSet<>(ret));
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about double wrapping as in the other PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the double wrap here to just directly return the unmodifiableSet

@akang31 akang31 merged commit ee954c2 into 1.x Jan 19, 2024
2 checks passed
@akang31 akang31 deleted the 1.x-instrumentation branch January 19, 2024 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants