Skip to content

Conversation

@yuandrew
Copy link
Contributor

@yuandrew yuandrew commented Sep 10, 2025

What was changed

  1. Set span kind, server for inbound, and client for outbound
  2. Also removed ToHeader and FromHeader, they appear to directly be associated with if inbound or outbound
  3. Don't mark benign exceptions as Errors for otel status. Also avoid setting error tag for opentracing

Why?

  1. Match other SDKs
  2. benign exceptions are expected errors, shouldn't be marking otel status as actual errors

Checklist

  1. Closes Set Span Kinds in Otel tracer interceptors #2024 and [Feature Request] Reclassify Benign Application errors in OpenTelemetry #2034

  2. How was this tested:

Added tests

  1. Any docs updates needed?

Note

Specify span kind (client/server) based on header direction, disallow both flags simultaneously, and only set error status for non-benign ApplicationErrors with accompanying tests.

  • OpenTelemetry tracing:
    • Span kind: Choose trace.SpanKindClient when ToHeader is set; default to trace.SpanKindServer. Prevent both ToHeader and FromHeader from being set. Pass trace.WithSpanKind into span start.
    • Error handling: Always RecordError; set status to codes.Error only if the error is not a benign temporal.ApplicationError (helper isBenignApplicationError).
    • Tests: Add TestSpanKind and TestBenignErrorSpanStatus to validate span kind selection and benign error status behavior.

Written by Cursor Bugbot for commit 101db75. This will update automatically on new commits. Configure here.

@yuandrew yuandrew requested a review from a team as a code owner September 10, 2025 23:31
}
}

spanKind := trace.SpanKindServer
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this line up roughly with what other SDKs like dotnet or python do?

Copy link
Member

@cretz cretz Sep 11, 2025

Choose a reason for hiding this comment

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

I think so (though I think I just spotted a bug in Python for outbound signal child workflow)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

}
}

spanKind := trace.SpanKindServer
Copy link
Member

@cretz cretz Sep 11, 2025

Choose a reason for hiding this comment

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

I think so (though I think I just spotted a bug in Python for outbound signal child workflow)


func (t *tracerSpan) Finish(opts *interceptor.TracerFinishSpanOptions) {
if opts.Error != nil {
if opts.Error != nil && !isBenignApplicationError(opts.Error) {
Copy link
Member

Choose a reason for hiding this comment

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

I think our implementation may not have been doing the right thing here because we are not calling .RecordError, which I think we should always do on error regardless of whether benign (but status as error only for benign like you have here). I don't know if we consider now starting to record errors as a breaking/dangerous change, but probably not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at the godoc of RecordError, I think you're right. This doesn't seem like a dangerous change, but kinda breaking? But I feel like something we probably want to do, to fix behavior

@yuandrew yuandrew merged commit 7c0ebcf into temporalio:master Nov 14, 2025
14 checks passed
@yuandrew yuandrew deleted the otel-span-kind branch November 14, 2025 17:44
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.

Set Span Kinds in Otel tracer interceptors

3 participants