Skip to content

Commit a91d7ad

Browse files
committed
internal/telemetry: use correct span kind for server
1 parent 6e6bd76 commit a91d7ad

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

internal/telemetry/telemetry.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,22 @@ type RPCInfo struct {
6464
// semantic convensions: https://opentelemetry.io/docs/specs/semconv/rpc/rpc-spans/#span-name.
6565
func StartServerSpan(ctx context.Context, tracer trace.Tracer, rpc RPCInfo, others ...Attribute) (context.Context, func(error)) {
6666
var (
67-
name = fmt.Sprintf("%s.%s/%s", rpc.System, rpc.Service, rpc.Method)
68-
attrs = []Attribute{
67+
name = fmt.Sprintf("%s.%s/%s", rpc.System, rpc.Service, rpc.Method)
68+
attributes = append([]Attribute{
6969
semconv.RPCSystemKey.String(rpc.System),
7070
semconv.RPCServiceKey.String(rpc.Service),
7171
semconv.RPCMethodKey.String(rpc.Method),
7272
semconv.RPCJSONRPCRequestID(rpc.RequestID),
73-
}
73+
},
74+
others...,
75+
)
7476
)
75-
ctx, _, end := startSpan(ctx, tracer, name, append(attrs, others...)...)
76-
return ctx, end
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)
7783
}
7884

7985
// startSpan creates an internal span.

0 commit comments

Comments
 (0)