Documentation
¶
Overview ¶
Package trace provides distributed tracing context helpers for APM instrumentation.
Index ¶
- func ContinueTrace(ctx context.Context) (context.Context, string)
- func GenerateSpanID() string
- func GenerateTraceID() string
- func GetParentID(ctx context.Context) string
- func GetSpanID(ctx context.Context) string
- func GetTraceContext(ctx context.Context) (traceID, spanID, parentID string)
- func GetTraceID(ctx context.Context) string
- func StartTrace(ctx context.Context) (context.Context, string, string)
- func WithNewSpan(ctx context.Context) (context.Context, string)
- func WithSpan(ctx context.Context, spanID string) context.Context
- func WithTrace(ctx context.Context, traceID, spanID string) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContinueTrace ¶
ContinueTrace continues an existing trace with a new span. If the context has no trace ID, creates a new trace. Returns the updated context and the new span ID.
func GenerateSpanID ¶
func GenerateSpanID() string
GenerateSpanID generates a new random span ID (16 hex characters). A span ID represents a single operation within a trace.
func GenerateTraceID ¶
func GenerateTraceID() string
GenerateTraceID generates a new random trace ID (32 hex characters). A trace ID represents a single distributed trace across multiple services.
func GetParentID ¶
GetParentID returns the parent span ID from the context, or empty string if not set.
func GetTraceContext ¶
GetTraceContext extracts all trace context values from the context. Returns traceID, spanID, and parentID.
func GetTraceID ¶
GetTraceID returns the trace ID from the context, or empty string if not set.
func StartTrace ¶
StartTrace creates a new trace context with fresh trace and span IDs. Returns the new context, trace ID, and span ID.
func WithNewSpan ¶
WithNewSpan creates a new span ID and updates the context. Returns the new context and the generated span ID.
Types ¶
This section is empty.