tracectx

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tracectx holds W3C trace context: it parses and formats traceparent headers and carries the current span in a context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSpanID

func NewSpanID() (id [8]byte)

NewSpanID returns a random span ID.

func NewTraceID

func NewTraceID() (id [16]byte)

NewTraceID returns a random trace ID.

func With

With returns a copy of ctx carrying sc as the current span.

Types

type SpanContext

type SpanContext struct {
	TraceID [16]byte
	SpanID  [8]byte
	Sampled bool
}

SpanContext identifies a span within a trace.

func From

func From(ctx context.Context) (SpanContext, bool)

From returns the current span of ctx.

func Parse

func Parse(h string) (SpanContext, bool)

Parse parses a version-00 traceparent header. It returns false for anything else, so a malformed header starts a new trace instead of failing the request.

func (SpanContext) Traceparent

func (sc SpanContext) Traceparent() string

Traceparent formats sc as a version-00 traceparent header.

func (SpanContext) Valid

func (sc SpanContext) Valid() bool

Valid reports whether both IDs are non-zero.

Jump to

Keyboard shortcuts

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