Skip to content

Conversation

@software-artificer
Copy link

@software-artificer software-artificer commented Dec 5, 2025

Make sure we add exception.type field to span events any time we report an error as an exception.

Motivation

This change is addressing the issue described in #242, where traces that are sent to Datadog that contained errors would not properly link and render, causing an error in Datadog's UI: Missing error message and stack trace.

Solution

Datadog apparently requires at least the exception.message and exception.type fields to be present.

Closes #242
Closes tokio-rs/tracing#2648

Make sure we always append `exception.type` to the span events any time
we convert an error to an exception. This is required to make Datadog
platform happy and avoid the "Missing error message and stack trace"
error.
Current default branch is broken, failing the build. I am doing a change
that I think is appropriate here, but open to feedback.
Comment on lines +147 to +150
status,
} => {
builder.attributes.get_or_insert(Vec::new()).push(key_value);
builder.status = status.clone();
Copy link
Author

Choose a reason for hiding this comment

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

Please double-check this for me. At the moment, the default branch if failing to build, because the status field isn't properly matched. I think I am doing the right thing here, but if I should rather ignore the status instead of setting it on the builder, please let me know and I will make an update.

@software-artificer software-artificer marked this pull request as ready for review December 5, 2025 04:20
Use `Unknown` as an `exception.type` instead of `dyn ...` types as per
our conversation in the original issue.
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.

#[instrument(err)] causes broken traces in Datadog #[tracing::instrument(err)] doesn't work with opentelemetry / datadog

1 participant