Skip to content

Commit cd9665f

Browse files
committed
StartServerSpan had the wrong spankind
1 parent a91d7ad commit cd9665f

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

internal/telemetry/telemetry.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ func Int64Attribute(key string, val int64) Attribute {
4040
return attribute.Int64(key, val)
4141
}
4242

43-
// StartSpan creates an internal span.
43+
// StartSpan creates a SpanKind=INTERNAL span.
4444
func StartSpan(ctx context.Context, spanName string, attributes ...Attribute) (context.Context, trace.Span, func(error)) {
4545
return StartSpanWithTracer(ctx, otel.Tracer(""), spanName, attributes...)
4646
}
4747

4848
// StartSpanWithTracer requires a tracer to be passed in and creates a SpanKind=INTERNAL span.
4949
func StartSpanWithTracer(ctx context.Context, tracer trace.Tracer, name string, attributes ...Attribute) (context.Context, trace.Span, func(error)) {
50-
return startSpan(ctx, tracer, name, attributes...)
50+
return startSpan(ctx, tracer, trace.SpanKindInternal, name, attributes...)
5151
}
5252

5353
// RPCInfo contains information about the RPC request.
@@ -74,18 +74,13 @@ func StartServerSpan(ctx context.Context, tracer trace.Tracer, rpc RPCInfo, othe
7474
others...,
7575
)
7676
)
77-
ctx, span := tracer.Start(ctx, name, trace.WithSpanKind(trace.SpanKindInternal))
78-
79-
if len(attributes) > 0 {
80-
span.SetAttributes(attributes...)
81-
}
82-
return ctx, endSpan(span)
77+
ctx, _, end := startSpan(ctx, tracer, trace.SpanKindServer, name, attributes...)
78+
return ctx, end
8379
}
8480

85-
// startSpan creates an internal span.
86-
func startSpan(ctx context.Context, tracer trace.Tracer, spanName string, attributes ...Attribute) (context.Context, trace.Span, func(error)) {
87-
ctx, span := tracer.Start(ctx, spanName, trace.WithSpanKind(trace.SpanKindInternal))
88-
81+
// startSpan creates a span with the given kind.
82+
func startSpan(ctx context.Context, tracer trace.Tracer, kind trace.SpanKind, spanName string, attributes ...Attribute) (context.Context, trace.Span, func(error)) {
83+
ctx, span := tracer.Start(ctx, spanName, trace.WithSpanKind(kind))
8984
if len(attributes) > 0 {
9085
span.SetAttributes(attributes...)
9186
}

0 commit comments

Comments
 (0)