From cd9665f1074706e90bf80440813e7f60cd0b2bab Mon Sep 17 00:00:00 2001 From: jonny rhea Date: Thu, 8 Jan 2026 10:32:03 -0600 Subject: [PATCH] StartServerSpan had the wrong spankind --- internal/telemetry/telemetry.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/internal/telemetry/telemetry.go b/internal/telemetry/telemetry.go index 19d183542c..7a3b86e6d5 100644 --- a/internal/telemetry/telemetry.go +++ b/internal/telemetry/telemetry.go @@ -40,14 +40,14 @@ func Int64Attribute(key string, val int64) Attribute { return attribute.Int64(key, val) } -// StartSpan creates an internal span. +// StartSpan creates a SpanKind=INTERNAL span. func StartSpan(ctx context.Context, spanName string, attributes ...Attribute) (context.Context, trace.Span, func(error)) { return StartSpanWithTracer(ctx, otel.Tracer(""), spanName, attributes...) } // StartSpanWithTracer requires a tracer to be passed in and creates a SpanKind=INTERNAL span. func StartSpanWithTracer(ctx context.Context, tracer trace.Tracer, name string, attributes ...Attribute) (context.Context, trace.Span, func(error)) { - return startSpan(ctx, tracer, name, attributes...) + return startSpan(ctx, tracer, trace.SpanKindInternal, name, attributes...) } // RPCInfo contains information about the RPC request. @@ -74,18 +74,13 @@ func StartServerSpan(ctx context.Context, tracer trace.Tracer, rpc RPCInfo, othe others..., ) ) - ctx, span := tracer.Start(ctx, name, trace.WithSpanKind(trace.SpanKindInternal)) - - if len(attributes) > 0 { - span.SetAttributes(attributes...) - } - return ctx, endSpan(span) + ctx, _, end := startSpan(ctx, tracer, trace.SpanKindServer, name, attributes...) + return ctx, end } -// startSpan creates an internal span. -func startSpan(ctx context.Context, tracer trace.Tracer, spanName string, attributes ...Attribute) (context.Context, trace.Span, func(error)) { - ctx, span := tracer.Start(ctx, spanName, trace.WithSpanKind(trace.SpanKindInternal)) - +// startSpan creates a span with the given kind. +func startSpan(ctx context.Context, tracer trace.Tracer, kind trace.SpanKind, spanName string, attributes ...Attribute) (context.Context, trace.Span, func(error)) { + ctx, span := tracer.Start(ctx, spanName, trace.WithSpanKind(kind)) if len(attributes) > 0 { span.SetAttributes(attributes...) }