Documentation
¶
Index ¶
Constants ¶
const ( // Version represents the maximum `traceparent` header version that is fully supported. // The library attempts optimistic forwards compatibility with higher versions. Version = 0 )
Variables ¶
var ( // ErrInvalidFormat occurs when the format is invalid, such as if there are missing characters // or a field contains an unexpected character set. ErrInvalidFormat = errors.New("tracecontext: Invalid traceparent format") // ErrInvalidVersion occurs when the encoded version is invalid, i.e., is 255. ErrInvalidVersion = errors.New("tracecontext: Invalid traceparent version") // ErrInvalidTraceID occurs when the encoded trace ID is invalid, i.e., all bytes are 0 ErrInvalidTraceID = errors.New("tracecontext: Invalid traceparent trace ID") // ErrInvalidSpanID occurs when the encoded span ID is invalid, i.e., all bytes are 0 ErrInvalidSpanID = errors.New("tracecontext: Invalid traceparent span ID") )
Functions ¶
This section is empty.
Types ¶
type Flags ¶
type Flags struct { // Recorded indicates that at least one span in the trace may have been recorded. // Tracing systems are advised to record all new spans in recorded traces, as incomplete traces may lead to // a degraded tracing experience. Recorded bool }
Flags contain recommendations from the caller relevant to the whole trace, e.g., for sampling.
type TraceParent ¶
type TraceParent struct { // Version represents the version used to encode the `TraceParent`. // Typically, this is the minimum of this library's supported version and the version of the header from which the `TraceParent` was decoded. Version uint8 // TraceID is the trace ID of the whole trace, and should be constant across all spans in a given trace. // A `TraceID` that contains only 0 bytes should be treated as invalid. TraceID [16]byte // SpanID is the span ID of the span from which the `TraceParent` was derived, i.e., the parent of the next span that will be started. // Span IDs should be unique within a given trace. // A `TraceID` that contains only 0 bytes should be treated as invalid. SpanID [8]byte // Flags indicate behaviour that is recommended when handling new spans. Flags Flags }
TraceParent indicates information about a span and the trace of which it is part, so that child spans started in the same trace may propagate necessary data and share relevant behaviour.
func Parse ¶
func Parse(b []byte) (TraceParent, error)
Parse attempts to decode a `TraceParent` from a byte array. It returns an error if the byte array is incorrectly formatted or otherwise invalid.
func ParseString ¶
func ParseString(s string) (TraceParent, error)
ParseString attempts to decode a `TraceParent` from a string. It returns an error if the string is incorrectly formatted or otherwise invalid.
func (TraceParent) String ¶
func (tp TraceParent) String() string
String encodes the `TraceParent` into a string formatted according to the W3C spec. The string may be invalid if any fields are invalid, e.g., if the `TraceID` contains only 0 bytes.