Skip to content

Conversation

yuandrew
Copy link
Contributor

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?

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

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

Choose a reason for hiding this comment

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

Open tracing is deprecated, not sure we should bother fixing it here/ do a release to publish this

// from the header or write to the header, where outbound means the span should
// be placed on the Temporal header, and inbound means the parent span can be
// retrieved from the Temporal header.
Outbound bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: A change like this would break compatibility between new SDK and old tracing modules since they are versioned independently

Copy link
Contributor

Choose a reason for hiding this comment

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

This is also part of the SDK public API so technically our backwards compatibility guarantees apply.

}
}

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)

}
}

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.

func isBenignApplicationError(err error) bool {
var appErr *temporal.ApplicationError
if temporal.IsApplicationError(err) {
if errors.As(err, &appErr) {
Copy link
Member

Choose a reason for hiding this comment

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

Per #1925 (comment), we should only look at the top-level error to determine whether benign. Mimic the isBenignApplicationError already in internal/error.go.

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