Skip to content

Conversation

@daniel-grumberg
Copy link
Contributor

@daniel-grumberg daniel-grumberg commented Dec 15, 2025

Motivation:

Span status is relied upon by application developers to quickly discover spans that have thrown a exception.

Modifications:

Ensure that all tracer protocols set the span status to .error when the underlying operation closure throws during execution.

Result:

When an error is thrown from a withSpan operation closure the underlying span has an .error span status code on return.

Closes: #200

**Motivation:**

Span status is relied upon by application developers to
quickly discover spans that have thrown a exception.

**Modifications:**

Ensure that all tracer protocols set the span status to `.error` when
the underlying operation closure throws during execution.

**Result:**

When an error is thrown from a `withSpan` operation closure the
underlying span has an `.error` span status code on return.
@ktoso ktoso added the 🔨 semver/patch No public API change. label Dec 15, 2025
Copy link
Member

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

Hmm I can’t think of a reason why we wouldn’t want to set the status to error in the withSpan APIs as the entire span is failed then.

FYI @simonjbeaumont @slashmo for otel interaction, however I believe this is compatible and valid within otel rules as well.

We should not have record error cause a status change but I agree with WithSpan APIs should.

@daniel-grumberg
Copy link
Contributor Author

Yeah I purposefully only did it in the withSpan APIs for that purpose.

@ktoso ktoso merged commit b642953 into apple:main Dec 16, 2025
42 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

withSpan functions should set span status to error when an exception is thrown

2 participants