-
-
Notifications
You must be signed in to change notification settings - Fork 216
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
Activity.SetTag
not processed as expected
#4043
Comments
Assigning to @getsentry/support for routing ⏲️ |
@nefarius OpenTelemetry doesn't (as far as I'm aware) have any equivalent of : SentrySdk.ConfigureScope(scope =>
{
scope.SetTag("myApp.userId", request.UserId);
}); Scope is concept specific to Sentry. It's basically a place where you can store ambient contextual data that will get attached to all/any events that get sent to Sentry (including transactions/spans for traces). In the .NET implementation of OpenTelemetry, an
... would set a "tag" on the specific span represented by the current activity. I put "tag" in quotes, since the concept of a tag also doesn't really exist in OpenTelemetry. This is the terminology Microsoft used in their implementation of OpenTelemetry (which they built before OTel was even a thing). Activity.Tags get mapped to OpenTelemetry Attributes... and we map OpenTelemetry Attributes to SentrySpan.Data. In any case, the "tag" won't be applied to any other spans and whether So you might not be seeing the Tag as you're expecting for various reasons:
You can see a demonstration of setting the tag on a specific span, in our samples: sentry-dotnet/samples/Sentry.Samples.OpenTelemetry.Console/Program.cs Lines 37 to 44 in cdbb4bc
Which looks like this when it shows up in Sentry: ![]() |
Thanks a lot for this in-depth response. I will try to check everything you mentioned and see what works and what doesn't 👍 |
Yes, correct, I assumed this was the case, wasn't aware of this "tags vs extra data" distinction. |
Alright I try to summarize what I think I found to be the case. Sadly I have to redact a lot from the production environment so I can't just post JSON and unedited screenshot examples here. So in my HTTP endpoint handler, if I dump
|
Activity.SetTag
not processedActivity.SetTag
not processed as expected
Thanks @nefarius. It would be nice if these ended up as Tags in Sentry but I'm not sure how we would do it... What we see, when capturing an OpenTelemetry span, is a bunch of The searchable Tags in Sentry are of type We attribute special meaning to some TagObjects based on the Key in the KVP. For example, we know the URL is important in ASP.NET Core apps:
The key is really the only thing that provide some hint... but we can't use this for custom tags that you've defined. If you wanted to make some specific TagObjects searchable, you could potentially write some custom logic in the SetBeforeSendTransaction callback to copy these across. In dotnet, in particular, I could think of one other way that we could do this to effectively add a custom property to the Activity class. It would be a bit weird though, since we'd be adding a Sentry specific extension to the Activity class - a property that would only be recognised by the Sentry open telemetry implementation... at which point I'd ask the question, "Why use OpenTelemetry at all?" If you're OK using Sentry specific instrumentation, Sentry has it's own Transactions and Spans (both of which support Tags out of the box)... |
You partially answered that already; it has to do with the history of when which tech has even seen the light of day. Before Sentry, I added OTEL integration into my servers; the .NET So what I learned from this; when relying on Sentry-only instrumentation and concepts, OTEL is just in the way and adds no benefits. .NET's own Tracing types like TL;DR: it's a bit messy thanks to history and there is no problem if Sentry-only concepts and patterns get used 👍 |
Yeah, it's unfortunately not as clean as we'd like. There's not always a 1 to 1 mapping between OTel and Sentry. I'll close this issue for the time. If there's anything you can think that we can do to improve the OTel integration, we're all ears though. |
Environment
SaaS (https://sentry.io/)
Steps to Reproduce
In my ASP.NET Core (.NET 8) endpoint handler I used
which worked finde before moving to Sentry. I added OTEL integration as per documentation. The tags do not show up in the Sentry Dashboard.
I change it to
and it works as expected.
Expected Result
Ideally
Activity.Current?.SetTag
would be routed to Sentry as expected or adjust the documentation on why this isn't possible/working.Actual Result
If I open a sample trace in
Trace View
or search for the tag value, I can not find it if usingActivity.SetTag
. I repeat the test withSentrySdk.ConfigureScope...
and it works.Product Area
Traces
Link
No response
DSN
No response
Version
No response
The text was updated successfully, but these errors were encountered: