Documentation ¶
Index ¶
- Constants
- func AttributeMapToKeyValue(attributes map[string]string) []attribute.KeyValue
- func GenTraceParentString(spanContext trace.SpanContext) string
- func NewContextFromDeterministicString(traceIDString string) context.Context
- func NewContextFromEnvTraceParent(ctx context.Context) (context.Context, error)
- func NewTraceProvider(ctx context.Context, serviceName string, ...) *sdktrace.TracerProvider
- func NewTracer(name string, provider trace.TracerProvider) trace.Tracer
Constants ¶
const TraceParentKey = "TRACEPARENT"
Variables ¶
This section is empty.
Functions ¶
func AttributeMapToKeyValue ¶
AttributeMapToKeyValue converts a map of attributes into a slice of attribute.KeyValue.
func GenTraceParentString ¶
func GenTraceParentString(spanContext trace.SpanContext) string
GenTraceParentString formats the TraceID and SpanID from the provided SpanContext and returns a W3C TraceParent string
func NewContextFromDeterministicString ¶
NewContextFromDeterministicString generates a new context with a deterministic trace ID and span ID from the provided strings. The returned context will include the trace ID, span ID, and trace flags set.
Example usage:
ctx := NewContextFromDeterministicString("foo", "bar") tracer := otel.Tracer("test-tracer") ctxSpan, span := tracer.Start(ctx, "test-span")
func NewContextFromEnvTraceParent ¶
NewContextFromEnvTraceParent generates a new context with a trace parent extracted from the `TRACEPARENT` environment variable. If the `TRACEPARENT` environment variable is not present, the function returns the provided context.
Example usage:
os.Setenv("TRACEPARENT", "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01") ctx := NewContextFromEnvTraceParent(context.Background())
func NewTraceProvider ¶
Types ¶
This section is empty.