Skip to content

feat(otel): add OpenTelemetry SpanProcessor, Propagator, Extractor #779

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

Merged
merged 21 commits into from
May 7, 2025

Conversation

lcian
Copy link
Member

@lcian lcian commented Apr 30, 2025

Creates a new crate sentry-opentelemetry for integration with OTEL.

The implementation is based on a SpanProcessor that creates and finishes Sentry spans on OTEL span start/end.
There's also a Propagator/Extractor that injects the metadata (e.g. HTTP headers) required for distributed tracing to work.
It's based on our implementation for JS and other SDKs (https://develop.sentry.dev/sdk/telemetry/traces/opentelemetry/).

The goal with this initial version is:

  • support OTEL <> Sentry span conversion and capturing
  • capture OTEL span attributes
  • link any messages/errors captured through the Sentry API to the correct spans, assuming that only the OTEL API is used to manage spans

Feedback appreciated on:

There are some todo items which will be addressed in follow-up PRs (not necessarily in this release).

@lcian lcian marked this pull request as ready for review April 30, 2025 12:52
@lcian
Copy link
Member Author

lcian commented Apr 30, 2025

Seems like Windows CI is getting stuck on test_captures_transaction for some reason. I'll stop it for now.

@lcian lcian linked an issue Apr 30, 2025 that may be closed by this pull request
Copy link
Member

@adinauer adinauer left a comment

Choose a reason for hiding this comment

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

Just gave this a quick glance and left some comments on what I noticed so far.

@lcian
Copy link
Member Author

lcian commented May 2, 2025

Just gave this a quick glance and left some comments on what I noticed so far.

Thank you!

@lcian
Copy link
Member Author

lcian commented May 2, 2025

Apparently we need to put each test in a different file or they will get stuck on Windows.

Copy link
Member

@Swatinem Swatinem left a comment

Choose a reason for hiding this comment

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

this looks reasonable to me.
Its a bit unfortunate how the lack of "onlyspans" means that you have to still deal with needing access to a TransactionOrSpan object instead of just being able to push finished spans with opaque parent ids into a global span sink.

Copy link
Member

@Swatinem Swatinem left a comment

Choose a reason for hiding this comment

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

lgtm

@sl0thentr0py
Copy link
Member

sl0thentr0py commented May 7, 2025

@lcian what is the end user experience of using this? I see you're adding stuff on the opentelemetry::{global} reference but how does a user configure their instrumentation along with this?

EDIT: nvm that's a docstring, ignore 🤦

Copy link
Member

@sl0thentr0py sl0thentr0py left a comment

Choose a reason for hiding this comment

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

wonderful, ship it

@lcian
Copy link
Member Author

lcian commented May 7, 2025

@lcian what is the end user experience of using this? I see you're adding stuff on the opentelemetry::{global} reference but how does a user configure their instrumentation along with this?

EDIT: nvm that's a docstring, ignore 🤦

Yeah this is the snippet to set it up
https://github.com/getsentry/sentry-rust/blob/lcian/feat/sentry-opentelemetry/sentry-opentelemetry/src/lib.rs#L18-43
Then they can just use OTEL APIs as normal (quite verbose unfortunately, I'm not sure if the UX is the same on other platforms).

Copy link
Member

@adinauer adinauer left a comment

Choose a reason for hiding this comment

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

LGTM, great work!

@lcian lcian enabled auto-merge (squash) May 7, 2025 13:34
@lcian lcian merged commit 3cc461a into master May 7, 2025
14 checks passed
@lcian lcian deleted the lcian/feat/sentry-opentelemetry branch May 7, 2025 13:39
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.

[OTEL] OpenTelemetry initial support
4 participants