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

Sets span kind (client/server) based on header direction and skips setting error status for benign ApplicationErrors; adds tests.

  • OpenTelemetry tracing (contrib/opentelemetry/tracing_interceptor.go):
    • Set span kind via trace.WithSpanKind (default server; client when ToHeader is true); error if both ToHeader and FromHeader are set.
    • Always record errors; set status to Error only for non-benign temporal.ApplicationError.
  • Tests (contrib/opentelemetry/tracing_interceptor_test.go):
    • Add TestSpanKind to verify client/server kinds.
    • Add TestBenignErrorSpanStatus to verify status handling for benign vs regular errors.

Written by Cursor Bugbot for commit f17f8b0. 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
// 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gotcha, reverting this change, although I added a check that ToHeader and FromHeader aren't both set. Technically that can be a breaking change, but this is correcting invalid usage, so should be fine?

}
}

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

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