Take the following snippet:
var tran = sentryTrace is not null
&& SentryTraceHeader.Parse(sentryTrace) is { } trace
? SentrySdk.StartTransaction("AppStart", "activity.load", trace)
: SentrySdk.StartTransaction("AppStart", "activity.load");
I marked this issue as a bug because we're crashing apps in case of a very "normal" (albeit not common) looking usage of the SDK.
One issue here is that if the service starting the trace had a DIsabled Sentry SDK, you could get all zeros here.
Repro: SDK starting the trace has a disabled DSN and does span.GetTraceHeader()
|
public virtual SentryTraceHeader GetTraceHeader() => SentryTraceHeader.Empty; |
So sentryTrace is not null or empty. And SentryTraceHeader.Parse successfully parses it.
But trying to start a trace, crashes my app.

So to use this API properly, one has to:
var tran = sentryTrace is not null
&& SentryTraceHeader.Parse(sentryTrace) is { } trace
&& trace.TraceId != SentryId.Empty
? SentrySdk.StartTransaction("AppStart", "activity.load", trace)
: SentrySdk.StartTransaction("AppStart", "activity.load");
Some ideas:
StartTransaction becomes more lenient. It shouldn't crash! So if the id provided is invalid. Just start a new one
SentryTraceHeader.Parse returns null if the parsed trace header is all 0's
I rather we go with 1. And I'd also argue we should change the API to take a trace that is nullable.
So using the API becomes a LOT easier:
var tran = SentrySdk.StartTransaction("AppStart", "activity.load", SentryTraceHeader.Parse(sentryTrace))
Alternatively, we could take a string overload for sentryTrace. But we need to consider that having 3 string parameters in a row and other overloads might make the API confusing. (for example, see this case)
Take the following snippet:
I marked this issue as a bug because we're crashing apps in case of a very "normal" (albeit not common) looking usage of the SDK.
One issue here is that if the service starting the trace had a DIsabled Sentry SDK, you could get all zeros here.
Repro: SDK starting the trace has a disabled DSN and does
span.GetTraceHeader()sentry-dotnet/src/Sentry/Internal/NoOpSpan.cs
Line 79 in 0e11682
So
sentryTraceis not null or empty. AndSentryTraceHeader.Parsesuccessfully parses it.But trying to start a trace, crashes my app.

So to use this API properly, one has to:
Some ideas:
StartTransactionbecomes more lenient. It shouldn't crash! So if the id provided is invalid. Just start a new oneSentryTraceHeader.Parsereturns null if the parsed trace header is all0'sI rather we go with 1. And I'd also argue we should change the API to take a
tracethat is nullable.So using the API becomes a LOT easier:
Alternatively, we could take a
stringoverload forsentryTrace. But we need to consider that having 3 string parameters in a row and other overloads might make the API confusing. (for example, see this case)