Skip to content

feat(otel): capture span events #795

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

lcian
Copy link
Member

@lcian lcian commented May 8, 2025

Adds capturing span events as Sentry events.
This is the behavior we have in other SDKs.

In the future we can consider ways to e.g. set tags on the event from special span attributes like we do in the tracing integration.

We don't capture a stack trace as we have no way to get it reliably. The event itself does not carry it, it's just a struct with name, timestamp and attributes.

Should it be opt-in?

@lcian lcian requested review from Swatinem and sl0thentr0py May 8, 2025 12:58
@lcian lcian marked this pull request as draft May 8, 2025 13:08
@lcian
Copy link
Member Author

lcian commented May 8, 2025

We could instead capture breadcrumbs, 1 Sentry event per OTEL event could be too much, let's discuss this.

sentry_span.set_data("otel.kind", convert_span_kind(data.span_kind));
for attribute in data.attributes {
sentry_span.set_data(attribute.key.as_str(), convert_value(attribute.value));
}
// TODO: read OTEL semantic convention span attributes and map them to the appropriate
// Sentry span attributes/context values

for event in data.events {
sentry_core::capture_event(convert_event(&event));
Copy link
Member

Choose a reason for hiding this comment

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

its a bit weird that you only get these on_end, and not when they happen.
if we decide to attach them as breadcrumbs, they should have proper ordering in relation to other breadcrumbs.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is true, on the other hand you know exactly which span they are in and you have the timestamp, so it shouldn't be much of a problem.

let mut contexts = BTreeMap::<String, Context>::new();
contexts.insert("otel".to_owned(), otel_context.into());
Event {
level: sentry_core::Level::Error,
Copy link
Member

Choose a reason for hiding this comment

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

doesn’t an otel event have a level?
for tracing we have this code that does different things depending on the event level.

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately in Rust they just carry a message, timestamp and attributes.
It seems that there is some misalignment in OTEL itself when it comes to this.
In e.g. Java they carry exceptions, so it makes sense to create errors out of them. @sl0thentr0py I don't think I mentioned this before when discussing this.

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.

2 participants