-
Notifications
You must be signed in to change notification settings - Fork 773
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] Added options for disabling signals #3639
Conversation
{ | ||
serviceProvider.Dispose(); | ||
|
||
return new NoopTracerProvider(); |
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.
@rajkumar-rangaraj Your design was returning the TracerProvider.Default
for this case. I had that, but decided to add a no-op instance instead. The reason being: User's code is probably calling dispose/shutdown on the instance returned from build invocation. Seemed risky to return them something shared which they might kill accidentally?
@@ -19,6 +19,7 @@ | |||
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="$(SystemReflectionEmitLightweightPkgVer)" Condition="'$(TargetFramework)' != 'net6.0'" /> | |||
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPkgVer)" /> | |||
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="$(MicrosoftExtensionsLoggingConfigurationPkgVer)" /> | |||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="$(MicrosoftExtensionsConfigurationEnvironmentVariablesPkgVer)" /> |
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.
Don't love adding this dependency, but we do make heavy use of environment variables so it didn't seem totally unreasonable?
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.
I'm not personally super concerned, but I have heard concern from end users regarding dependency bloat...
We could experiment with breaking out SDK configuration into its own package. This is kind of similar to what Java has with their auto-config module https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure
Yes! This is exactly what I had envisioned. I'd noted this in the description of #3376. The classes I put here https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Configuration was meant to be temporary. The class you introduce in this PR is effectively what I had in mind. I can move this stuff to unify things once your PR lands. |
Regarding the sprinkling... this class is an idea I had for centralizing our env var config in one more easily maintainable place. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3639 +/- ##
==========================================
+ Coverage 87.54% 87.67% +0.13%
==========================================
Files 283 284 +1
Lines 10283 10312 +29
==========================================
+ Hits 9002 9041 +39
+ Misses 1281 1271 -10
|
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day. |
Closed as inactive. Feel free to reopen if this PR is still being worked on. |
This is an alternative design for #3583 which fixes #3455.
Changes
We have a lot of environment variables sprinkled around the repo. There are issues like #2980 which are because we access envvars directly instead of through
IConfiguration
. This PR builds on top of #3533 to make it possible to useIConfiguration
to access settings.What I did here is introduce
SdkOptions
which contains flags for disabling the signals.SdkOptions
can be bound toIConfiguration
for users that want to drive it through JSON (or whatever). It will also look forOTEL_SDK_DISABLED
key usingIConfiguration
which means users can specify the flag through envvars, command-line, json, whatever. @alanwest I would imagine things like attribute limits would also go here and piggyback on theIConfiguration
stuff?Users calling the "Sdk.Create*ProviderBuilder" methods directly (including .NET Framework) will just get an
IConfiguration
automatically created from envvars.Essentially what I'm trying to do here is establish a better options pattern we can use throughout the repo (for exporters, instrumentation, etc.).
For auto-instrumentation case, I added a static registration method so it can disable the flags at runtime. Not the most elegant mechanism, but probably the easiest for consumption.
Examples
SdkOptions
to someIConfiguration
sectionOTEL_SDK_DISABLED
throughIConfiguration
Lot's of ways to do this. Command-line, using environment variables, etc. This is how it would look through appSettings.json:
Final
IConfiguration
will be a composite of all the sources users have configured.SdkOptions
will look for that key, basically.What to consider when comparing to the alternative design...
The issue I saw with #3583 is it is kind of a one-off thing. Auto-instrumentation would be tied to private bools via reflection. It would need to be changed if open-telemetry/opentelemetry-specification#2679 gets merged. It also seemed like a useful feature for users to be able to toggle SDK on/off via config. I tried to enable all of these things while also setting the foundation for better options/settings going forward.