Skip to content

add SdkTracerProvider.setScopeConfigurator() and support#7021

Merged
jack-berg merged 13 commits intoopen-telemetry:mainfrom
jackshirazi:add-experimental-settting-scope-configurator
Jan 29, 2025
Merged

add SdkTracerProvider.setScopeConfigurator() and support#7021
jack-berg merged 13 commits intoopen-telemetry:mainfrom
jackshirazi:add-experimental-settting-scope-configurator

Conversation

@jackshirazi
Copy link
Contributor

per discussion here from PR

@codecov
Copy link

codecov bot commented Jan 15, 2025

Codecov Report

Attention: Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.

Project coverage is 89.96%. Comparing base (c8da020) to head (8553a48).
Report is 24 commits behind head on main.

Files with missing lines Patch % Lines
...etry/sdk/trace/internal/SdkTracerProviderUtil.java 75.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7021      +/-   ##
============================================
+ Coverage     89.95%   89.96%   +0.01%     
- Complexity     6636     6668      +32     
============================================
  Files           745      748       +3     
  Lines         20010    20102      +92     
  Branches       1962     1970       +8     
============================================
+ Hits          17999    18085      +86     
- Misses         1415     1425      +10     
+ Partials        596      592       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jackshirazi
Copy link
Contributor Author

@open-telemetry/java-approvers any idea why the graal build is failing?

@trask
Copy link
Member

trask commented Jan 21, 2025

looks like it was a sporadic issue, @laurit re-ran and it's passing now

return sharedState.getSampler();
}

// currently not public as experimental
Copy link
Member

Choose a reason for hiding this comment

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

The pattern for giving access to these experimental features has been via Sdk{Signal}ProviderUtil, a public class in an internal package, with static helper methods for reflectively accessing package private methods.

For tracing, this is SdkTracerProviderUtil.

I'd recommend adding an accessor method there as part of this PR. If you do, please add javadoc to this pointing to that method.

If you choose to punt on that, let's add a TODO to followup:

Suggested change
// currently not public as experimental
// TODO: add public experimental accessor in SdkTracerProviderUtil

Speaking of followups, after landing this, should open an issue to track extending metrics and logs with the same capability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the static helper, and opened #7038 for extending to metrics and logs

return tracerEnabled;
}

void updateTracerConfig(TracerConfig tracerConfig) {
Copy link
Member

Choose a reason for hiding this comment

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

Removed a comment on this method which implied it may one day be public, since this class is package private and will stay that way.

*
* @see TracerConfig#configuratorBuilder()
*/
void setTracerConfigurator(ScopeConfigurator<TracerConfig> tracerConfigurator) {
Copy link
Member

Choose a reason for hiding this comment

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

Updated naming to mirror SdkTracerProviderBuilder, added javadoc pointing to the SdkTracerProviderUtil method for updatingl

final class ExtendedSdkTracer extends SdkTracer implements ExtendedTracer {
// TODO: add dedicated API for updating scope config.
@SuppressWarnings("FieldCanBeFinal") // For now, allow updating reflectively.
private boolean tracerEnabled;
Copy link
Member

Choose a reason for hiding this comment

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

Needed to make sure the updates are visible to ExtendedTracer#isEnabled(). Updated SdkTracer.tracerEnabled to be protected, and removed this field, such that ExtendedSdkTracer#isEnabled() resolves using the value from SdkTracer.tracerEnabled.

}

@Test
void setScopeConfigurator() {
Copy link
Member

Choose a reason for hiding this comment

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

New test to ensure changes reach ExtendedTracer#isEnabled() and have the desired affect.

@jack-berg
Copy link
Member

I realized we needed to make a few changes to ensure these updates reached ExtendedSdkTracer, and after pulling down the code to investigate how, realized it was just faster to make the changes than the comments. Tweaked a few other minor things along the way.

Good to go from my perspective.

We're officially dipping our toes into the world of dynamic config!

@jack-berg jack-berg merged commit 8e31bf4 into open-telemetry:main Jan 29, 2025
25 checks passed
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.

3 participants