Repository navigation
Description
Description:
See parent ticket for more project background.
We would like to investigate using OpenTelemetry's .NET SDK to replace Sentry performance package in our own SDK. This would allow our users to benefit from all of the instrumentation of the open standard's SDK, while allowing us to tailor the experience.
Requirement:
The OTel SDK should run the show in terms of instrumentations and collecting telemetry, our SDK should only do some fine tuning to ensure data is flagged for ingestion properly (OTel attributed as tags for example)
Open Point:
- Sentry will have a product ready OTLP endpoint, with this, we have an opportunity to exclude the transaction model all together from our implementation. It should be investigated if we need to adapt our existing trxn model.
- Does OTLP give us a simpler route?
Information:
Updated requirements
See Discord chat for context.
- When Sentry is initialized using OpenTelemetry instrumentation, calls to .StartSpan() or .StartChild() on the Sentry SDK should result in spans that fit seamlessly into the auto-instrumentation provided by OpenTelemetry.
- We also need to ensure the correct trace id is used regardless of whether the backend is otel or sentry only
Sentry Transactions with OTEL Child Spans
Currently leads to unexpected outcomes.
var transaction = SentrySdk.StartTransaction("Program", "Main");
try
{
Console.WriteLine("Hello World!");
using (var task = activitySource.StartActivity("Task 1"))
{
task?.SetTag("Answer", 42);
Thread.Sleep(100); // simulate some work
}
using (var task = activitySource.StartActivity("Task 2"))
{
task?.SetTag("Question", "???");
Thread.Sleep(100); // simulate some more work
}
Console.WriteLine("Goodbye cruel world...");
}
finally
{
transaction.Finish();
}The Sentry transaction gets ignored. If we turn on Debug mode we see the following warning:
Warning: Attempted to start a transaction via Sentry instrumentation when the SDK is configured for OpenTelemetry instrumentation. The transaction will not be created.
And as a result the two Activities show up as separate transactions:

We could run into this if people wanted to use OTel to take advantage of automatic tracing for some tech (e.g. Redis) but otherwise they had been instrumenting their app for performance using Sentry... so we probably need to fix this.
Scopes
Metadata
Metadata
Assignees
Projects
- StatusShow more project fieldsDone
Activity
[-].NET SDK[/-][+].NET SDK powered by OTel[/+]jamescrosswell commentedon Feb 23, 2024
A couple of thoughts:
Sentry.AspNetCorehas two bits of middleware... SentryMiddleware and SentryTracingMiddleware. Would the SentryTracingMiddleware be obsolete (replaced by OpenTelemetry tracing for ASP.NET Core)? All that we would really retain then would be the crash reporting?OTLP_ENDPOINT_URL? From what I can tell, you'd do that if Sentry was not running in the same process as the application that was generating the telemetry... so the telemetry would be serialized via json/protobuf or whatever and sent to the endpoint, where it got deserialized and processed/stored. In our case, if Sentry is running in the same process, perhaps we're better off retaining the SentrySpanProcessor to collect traces? Or are we thinking of removing this from the SDKs (i.e. the endpoints would sit on Sentry.io). Probably needs a bit of research/consideration...Overall, this seems like a really really big piece of work. We might need to break it down into bite sized chunks. Possibly merging Spans and Transactions would be a good first step?
bitsandfoxes commentedon Feb 29, 2024
This remains to be discussed. Ideally, users would not need to know or care where spans come from.
There is quite a big gap in what versions are supported by Sentry vs OTel. I'd go on a case-by-case basis to go with the one offering more/better/more detailed support.
jamescrosswell commentedon Mar 12, 2024
Transaction vs Span
Additionally
ITransactionTracercontains aGetLastActiveSpan() : ISpan?method, whichISpanTracerandSpanTracerlack.