12345678910111213141516171819202122232425 |
- package trace
- import (
- "context"
- "go.opentelemetry.io/otel/trace"
- )
- func SpanIDFromContext(ctx context.Context) string {
- spanCtx := trace.SpanContextFromContext(ctx)
- if spanCtx.HasSpanID() {
- return spanCtx.SpanID().String()
- }
- return ""
- }
- func TraceIDFromContext(ctx context.Context) string {
- spanCtx := trace.SpanContextFromContext(ctx)
- if spanCtx.HasTraceID() {
- return spanCtx.TraceID().String()
- }
- return ""
- }
|