mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
internal/telemetry: use correct span kind for server
This commit is contained in:
parent
6e6bd76fe3
commit
a91d7ad952
1 changed files with 11 additions and 5 deletions
|
|
@ -64,16 +64,22 @@ type RPCInfo struct {
|
||||||
// semantic convensions: https://opentelemetry.io/docs/specs/semconv/rpc/rpc-spans/#span-name.
|
// semantic convensions: https://opentelemetry.io/docs/specs/semconv/rpc/rpc-spans/#span-name.
|
||||||
func StartServerSpan(ctx context.Context, tracer trace.Tracer, rpc RPCInfo, others ...Attribute) (context.Context, func(error)) {
|
func StartServerSpan(ctx context.Context, tracer trace.Tracer, rpc RPCInfo, others ...Attribute) (context.Context, func(error)) {
|
||||||
var (
|
var (
|
||||||
name = fmt.Sprintf("%s.%s/%s", rpc.System, rpc.Service, rpc.Method)
|
name = fmt.Sprintf("%s.%s/%s", rpc.System, rpc.Service, rpc.Method)
|
||||||
attrs = []Attribute{
|
attributes = append([]Attribute{
|
||||||
semconv.RPCSystemKey.String(rpc.System),
|
semconv.RPCSystemKey.String(rpc.System),
|
||||||
semconv.RPCServiceKey.String(rpc.Service),
|
semconv.RPCServiceKey.String(rpc.Service),
|
||||||
semconv.RPCMethodKey.String(rpc.Method),
|
semconv.RPCMethodKey.String(rpc.Method),
|
||||||
semconv.RPCJSONRPCRequestID(rpc.RequestID),
|
semconv.RPCJSONRPCRequestID(rpc.RequestID),
|
||||||
}
|
},
|
||||||
|
others...,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
ctx, _, end := startSpan(ctx, tracer, name, append(attrs, others...)...)
|
ctx, span := tracer.Start(ctx, name, trace.WithSpanKind(trace.SpanKindInternal))
|
||||||
return ctx, end
|
|
||||||
|
if len(attributes) > 0 {
|
||||||
|
span.SetAttributes(attributes...)
|
||||||
|
}
|
||||||
|
return ctx, endSpan(span)
|
||||||
}
|
}
|
||||||
|
|
||||||
// startSpan creates an internal span.
|
// startSpan creates an internal span.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue