frostfs-node/pkg/tracing/trace.go

20 lines
436 B
Go
Raw Permalink Normal View History

package tracing
import (
"context"
"go.opentelemetry.io/otel/trace"
)
var emptyTraceID = [16]byte{}
// GetTraceID retrieves the trace ID from the provided context.
// It returns an empty string if no trace ID is found.
func GetTraceID(ctx context.Context) string {
span := trace.SpanFromContext(ctx)
if span == nil || span.SpanContext().TraceID() == emptyTraceID {
return ""
}
return span.SpanContext().TraceID().String()
}