Skip to content

Feature: Open Telemetry Support#2453

Merged
jamescrosswell merged 65 commits intomainfrom
feat/open-telemetry
Jul 5, 2023
Merged

Feature: Open Telemetry Support#2453
jamescrosswell merged 65 commits intomainfrom
feat/open-telemetry

Conversation

@jamescrosswell
Copy link
Copy Markdown
Collaborator

@jamescrosswell jamescrosswell commented Jun 28, 2023

Summary

Implementation for OpenTelemetry Support #2066.

Enables people to use OpenTelemetry .NET with Sentry. Essentially they can use the OpenTelemetry .NET SDK to instrument their application for tracing and have all of the information collected (plus error logs and all of Sentry's other goodness) available in their Sentry Dashboard!

Testing

I've tested a distributed application consisting of 3 x nodes:

  1. A python script instrumented using Sentry, which makes a call to...
  2. A minor variant of our Sentry.Samples.OpenTelemetry.AspNetCore application running on http://localhost:5092/, instrumented with OpenTelemetry .NET and Sentry, which makes a call to...
  3. A Flask server running on http://[localhost:5000] instrumented with Sentry

This tests that:

  • We capture the sentry-trace and baggage headers from inbound requests (from the python script)
  • Appropriate transactions/spans get created by the .NET SDK (tests SpanProcessor)
  • Trace information gets propagated correctly downstream to the Flask server (Tests SentryPropagator.Inject)

All of that shows up in Sentry like this:
image

Outstanding issues

This is something only our Javascript SDK has. None of the other Sentry SDKs support it.

It's not critical as we already capture errors through the normal exception handlers. It would only be an issue if a particular Otel instrumentation decided to not let exceptions bubble up, and only to report them as Otel events.

mattjohnsonpint and others added 30 commits June 14, 2023 21:47
jamescrosswell and others added 23 commits June 30, 2023 20:24
Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
Co-authored-by: Stefan Jandl <reg@bitfox.at>
Copy link
Copy Markdown
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with merging this and figuring out the init code on a follow up PR

Comment on lines +20 to +26
.AddSentry()
);

builder.WebHost.UseSentry(options =>
{
options.TracesSampleRate = 1.0;
options.UseOpenTelemetry();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good as init code. But do we override someone's propagator if they set something?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would yes... that happens in the AddSentry() call. See the comments on that extension:

The default TextMapPropagator to be used by OpenTelemetry.

If this parameter is not supplied, the will be used, which propagates the baggage header as well as Sentry trace headers.

The is required for Sentry's OpenTelemetry integration to work but you could wrap this in a CompositeTextMapPropagator if you needed other propagators as well.

Under the hood the OpenTelemetry SDK just stores this as a static property, so I think the composite propagator is the only way around it. We could try to do something fancy like, if this was set to something other than Noop, we read that out and stuff it in a composite property along with our SentryPropagator and then write it back... essentially emulating a List<TextMapPropagator>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenTelemetry Support

4 participants