trace

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSpanID

func GetSpanID(r *http.Request) string

GetSpanID returns the hex-encoded 8-byte span id if present.

func GetTraceID

func GetTraceID(r *http.Request) string

GetTraceID returns the hex-encoded 16-byte trace id if present.

func Middleware

func Middleware(opts Options) func(http.Handler) http.Handler

Middleware attaches trace/span IDs to request context and sets response header.

Types

type Options

type Options struct {
	// TrustIncoming strictly validates client-provided traceparent and uses it
	// if valid. When false, the middleware always generates a fresh trace ID.
	TrustIncoming bool
	// SampledFlag defaults to 01 (sampled). Set to 00 to turn off sampling bit.
	SampledFlag byte
}

Options controls middleware behaviour.

Jump to

Keyboard shortcuts

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