-
Notifications
You must be signed in to change notification settings - Fork 858
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
add SdkTracerProvider.setScopeConfigurator() and support #7021
base: main
Are you sure you want to change the base?
add SdkTracerProvider.setScopeConfigurator() and support #7021
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7021 +/- ##
============================================
- Coverage 89.95% 89.89% -0.06%
- Complexity 6636 6660 +24
============================================
Files 745 748 +3
Lines 20010 20095 +85
Branches 1962 1969 +7
============================================
+ Hits 17999 18064 +65
- Misses 1415 1437 +22
+ Partials 596 594 -2 ☔ View full report in Codecov by Sentry. |
@open-telemetry/java-approvers any idea why the graal build is failing? |
looks like it was a sporadic issue, @laurit re-ran and it's passing now |
@@ -100,6 +102,17 @@ public Sampler getSampler() { | |||
return sharedState.getSampler(); | |||
} | |||
|
|||
// currently not public as experimental |
There was a problem hiding this comment.
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:
// 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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
@@ -12,16 +12,12 @@ | |||
|
|||
/** {@link ExtendedSdkTracer} is SDK implementation of {@link ExtendedTracer}. */ | |||
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; |
There was a problem hiding this comment.
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
.
@@ -158,4 +161,67 @@ private static Stream<Arguments> tracerConfiguratorArgs() { | |||
Arguments.of(enableStartsWithD, scopeDog, enabled()), | |||
Arguments.of(enableStartsWithD, scopeDuck, enabled())); | |||
} | |||
|
|||
@Test | |||
void setScopeConfigurator() { |
There was a problem hiding this comment.
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.
I realized we needed to make a few changes to ensure these updates reached Good to go from my perspective. We're officially dipping our toes into the world of dynamic config! |
per discussion here from PR