tracing

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const TraceParentKey = "TRACEPARENT"

Variables

This section is empty.

Functions

func AttributeMapToKeyValue

func AttributeMapToKeyValue(attributes map[string]string) []attribute.KeyValue

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

func NewContextFromDeterministicString(traceIDString string) context.Context

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

func NewContextFromEnvTraceParent(ctx context.Context) (context.Context, error)

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

func NewTraceProvider(ctx context.Context, serviceName string, resourceAttributes []attribute.KeyValue) *sdktrace.TracerProvider

func NewTracer

func NewTracer(name string, provider trace.TracerProvider) trace.Tracer

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL