-
-
Notifications
You must be signed in to change notification settings - Fork 206
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
Experimenting with implicit OpenTelemetry initialization #3229
base: main
Are you sure you want to change the base?
Conversation
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
- Experimenting with implicit OpenTelemetry initialization ([#3229](https://github.com/getsentry/sentry-dotnet/pull/3229)) If none of the above apply, you can opt out of this check by adding |
No way around this? We'd essentially be tying the sdk to OTels SDK and it's a no return thing with lots of things to be aware of |
this could be a good thing before we commit to anything. A list of things we'd be losing and getting by changing for example. Suggestion migration path. etc. It's a big enough change the would benefit having good upfront research and detailed documentation of what this would mean to us. It's 4 years worth of installations literally tens of thousands of apps out there at minimum that rely on this |
I'll look into abstracting tracing activities (like creating/finishing spans) out into an interface with the specific implementation of that interface (Sentry vs OTEL) as something that gets registered during Init. |
Playing around with one idea to implement:
This is a total hack at the moment, just to get an idea of the kinds of challenges involved.
Approach
OpenTelemetry Tracing is configured via a Static API that returns a
TracerProviderBuilderBase
.In the context of a Console application especially (where there's no common
IServiceCollection
for DI), it's relatively difficult to work out whether OpenTelemetry has already been initialized or not. The OpenTelemetry static API doesn't provide anSdk.Current
property or anything similar.However one possible solution might be to leverage our own AddSentry extension method:
sentry-dotnet/src/Sentry.OpenTelemetry/TracerProviderBuilderExtensions.cs
Lines 30 to 35 in 818e404
If we always initialise OpenTelemetry when initializing Sentry, and we do so using the above extension method... we can guarantee it will be called at least once... If this extension method gets called twice, we know the initialization we made internally was unecessary and can either skip our own initialization of the Otel SDK or dispose of any
TracerProvider
we created previously.Broadly speaking, this seems to work... there are a few challenges to making this production ready however.
Challenges
Sdk.CreateTracerProviderBuilder
method. In an ASP.NET Core app we would need to use the OpenTelemetryBuilder extensions instead.