Repository navigation
Description
ASP.NET Core 3.0+ have support to W3C context propagation out of the box.
The current SDK already has an options to control whether to read Activity data and some data is already read.
The goal is to read the new values and enhance the SDK and possibly the protocol to read them.
Research
I did a bit of digging into this. From the W3C Spec:
Design Overview
Trace context is split into two individual propagation fields supporting interoperability and vendor-specific extensibility:
traceparentdescribes the position of the incoming request in its trace graph <...snip...>tracestateextends traceparent with vendor-specific data represented by a set of name/value pairs. <...snip...>
Given that the data in tracestate is vendor specific, we're mainly interested in the traceparent then.
Traceparent Header
The traceparent HTTP header field identifies the incoming request in a tracing system. It has four fields:
- version - specifies the version of the traceparent header.
- trace-id - used to uniquely identify a distributed trace through a system
- parent-id - the ID of this request as known by the caller
- trace-flags - an 8-bit field that controls tracing flags such as sampling, trace level, etc.
Nothing in the W3C Traceparent Header itself is relevant beyond Sentry's Open Telemetry Integration then.
It looks like what we're more interested in is anything that could be gleaned from System.Diagnostics.Activity.Current. In the context of an ASP.NET [Core] application, everything that Microsoft currently store in there is to facilitate distributed tracing. I think the only time it might contain anything else is if one of our SDK users or some third party library was explicitly storing stuff in Activity.Tags. If they're doing that, then setting SentryOptions.IncludeActivityData will already ensure we capture this.
Activity
alesdvorakcz commentedon May 30, 2021
Would be nice if sentry tracing would be compatible with default dotnet core distributed tracing. Are there any plans for that?
bruno-garcia commentedon May 31, 2021
@alesdvorakcz could you please elaborate what are your expectations in that regard?
Using the W3C trace headers? Something else?
alesdvorakcz commentedon Jun 1, 2021
Yes exactly. dotnet core has build in tracing, from .NET 5 it is using open telemetry standard from W3C. It works trough System.Diagnostics.Activity and System.Diagnostics.ActivitySource classes and it should be well integrated with many dotnet core libraries.
I think it would be great if sentry could connect to this system so there is no need to create other Spans/Activities specifically for sentry.
More info in official docs
bruno-garcia commentedon Jun 1, 2021
That aligns with the goals of this issue. Thanks for sharing.
ccurrens commentedon Mar 3, 2022
Any update on this? Not having this greatly reduces the usefulness of the SDK.
In particular, third-party libraries that are already instrumented using
Activitywon't include span information. So instead, we would have to wrap all calls with our own calls toStartChild. Additionally, the code in our project was already instrumented withActivity, so to get value out of this, we have to start calling theSentrySDK.*methods directly.mattjohnsonpint commentedon Oct 20, 2022
https://learn.microsoft.com/en-us/dotnet/core/diagnostics/distributed-tracing-instrumentation-walkthroughs
[-]Read Activity data into event[/-][+]Read Activity data into event (OTEL)[/+]mattjohnsonpint commentedon Nov 16, 2022
Just an update for everyone. This is still on our radar, and we're planning out how it would work exactly. We'd like to have support for Open Telemetry in the base .NET SDK, and integrate with ASP.NET Core's support where appropriate. I'm very open to feedback and suggestions of exactly how this would work and what the APIs would look like.
David Fowler recently posted this thread on Twitter:
https://twitter.com/davidfowl/status/1588942067157594112
We could take a similar approach. Or we could try to do more automagically. Thoughts?
jamescrosswell commentedon Jul 6, 2023
@bruno-garcia is there anything additional implied in this issue that isn't already covered by the work we're doing on OpenTelemetry or would releasing
Sentry.OpenTelementryclose this issue?bruno-garcia commentedon Jul 7, 2023
I didn't look into what's available. The goal of the ticket was to find out opportunities and enhance our context/scope with that data when available. So feel free to close if that's done.