Skip to content

Add OTel-native YARPC tracing interceptor - #2523

Open
AmritM18 wants to merge 1 commit into
yarpc:mainfrom
AmritM18:amritmatharu-otel-yarpc-interceptor
Open

Add OTel-native YARPC tracing interceptor#2523
AmritM18 wants to merge 1 commit into
yarpc:mainfrom
AmritM18:amritmatharu-otel-yarpc-interceptor

Conversation

@AmritM18

Copy link
Copy Markdown
Contributor

Prerequisite for dropping the OpenTracing bridge. tracingcore already builds a native trace.TracerProvider, but wraps it in opentracingbridge.NewUberBridgeTracer because yarpcfx only accepts an opentracing.Tracer, so every YARPC span goes through the bridge. This gives YARPC an OTel entry point so jaegerfx can pass the provider straight through.

PR is still in progress as I put together the full picture.

@CLAassistant

CLAassistant commented Jul 30, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@AmritM18
AmritM18 force-pushed the amritmatharu-otel-yarpc-interceptor branch 5 times, most recently from e273ce1 to 54ae0c8 Compare August 11, 2026 08:54
@pulkit4tech
pulkit4tech force-pushed the amritmatharu-otel-yarpc-interceptor branch from 54ae0c8 to b750e5a Compare August 14, 2026 11:56
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/propagation"
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is this the most recent version that we might use? (latest is v1.45)

// commonOTelAttributes are the static attributes set on every span, matching
// commonTracingTags on the OpenTracing side.
var commonOTelAttributes = []attribute.KeyValue{
attribute.String("go.version", runtime.Version()),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

we can omit go.version, the tracer itself adds this tag

// commonTracingTags on the OpenTracing side.
var commonOTelAttributes = []attribute.KeyValue{
attribute.String("go.version", runtime.Version()),
attribute.String("component", tracingComponentName),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

does this name differentiate from the existing instrumentation?

func (t *tracedOTelClientStream) ReceiveMessage(ctx context.Context) (*transport.StreamMessage, error) {
msg, err := t.clientStream.ReceiveMessage(ctx)
if err != nil {
return nil, t.closeWithErr(err)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What is the lifecycle of this span, is it per stream or per message?
If it is created during stream start, then it should be Ended when the stream finishes; and not when a message errors.

func wrapOTelClientStream(s *tracedOTelClientStream) *transport.ClientStream {
wrapped, err := transport.NewClientStream(s)
if err != nil {
s.span.End()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

need to set error status/etc

Comment on lines +235 to +238
// An application error without a code has no numeric equivalent, so the
// status code attribute is a string here and an int elsewhere. This
// matches the OpenTracing interceptor.
span.SetAttributes(attribute.String(rpcStatusCodeTag, applicationError))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this string/int split is a bit confusing, maybe we should use a different key

Comment on lines +226 to +229
// The error message is deliberately not recorded on the span. It can carry
// request data, and the OpenTracing interceptor never emitted it either.
span.SetStatus(codes.Error, "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

it is desirable to record the error message on the span; could we make this configurable?

@vprithvi

Copy link
Copy Markdown

could you take a quick peek at https://github.com/grpc/grpc-go/tree/538bb2f7af6e36be46ec1d2ae90f65b972f14083/stats/opentelemetry to see if there is anything we can learn?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants