Documentation ¶
Index ¶
Constants ¶
const ( // MaxStateEntries is the maximum number of items in `tracestate` as defined by // https://www.w3.org/TR/trace-context/#tracestate-header-field-values MaxStateEntries = 32 // TraceParentHeader is the W3C trace parent header name as defined by https://www.w3.org/TR/trace-context/ TraceParentHeader = "traceparent" // TraceStateHeader is the W3C trace state header name as defined by https://www.w3.org/TR/trace-context/ TraceStateHeader = "tracestate" )
const VendorInstana = "in"
VendorInstana is the Instana vendor key in the `tracestate` list
Variables ¶
var ( // ErrContextNotFound is an error retuned by w3ctrace.Extract() if provided HTTP headers does not contain W3C trace context ErrContextNotFound = errors.New("no w3c context") // ErrContextCorrupted is an error retuned by w3ctrace.Extract() if provided HTTP headers contain W3C trace context in unexpected format ErrContextCorrupted = errors.New("corrupted w3c context") // ErrUnsupportedVersion is an error retuned by w3ctrace.Extract() if the version of provided W3C trace context is not supported ErrUnsupportedVersion = errors.New("unsupported w3c context version") )
Functions ¶
func TracingHandlerFunc ¶
func TracingHandlerFunc(handler http.HandlerFunc) http.HandlerFunc
TracingHandlerFunc is an HTTP middleware that forwards the W3C context found in request with the response
Types ¶
type Context ¶
Context represents the W3C trace context
func Extract ¶
Extract extracts the W3C trace context from HTTP headers. Returns ErrContextNotFound if provided value doesn't contain traceparent header.
type Flags ¶ added in v1.12.1
type Flags struct {
Sampled bool
}
Flags contains the trace flags as defined by https://www.w3.org/TR/trace-context/#trace-flags
type Parent ¶ added in v1.12.1
Parent represents trace parent extracted from `traceparent` header
func ParseParent ¶ added in v1.12.1
ParseParent parses the value of `traceparent` header according to the version defined in the first field
type State ¶ added in v1.12.1
type State struct {
// contains filtered or unexported fields
}
State is list of key=value pairs representing vendor-specific data in the trace context
func FormStateWithInstanaTraceStateValue ¶ added in v1.42.1
FormStateWithInstanaTraceStateValue returns a new state prepended with the provided Instana value. If the original state had an Instana list member pair, it is discarded/overwritten.
func ParseState ¶ added in v1.12.1
ParseState parses the value of `tracestate` header. Empty list items are omitted.
func (State) FetchInstanaTraceStateValue ¶ added in v1.42.1
FetchInstanaTraceStateValue retrieves the value of the Instana tracestate list member, if any.
func (State) String ¶ added in v1.12.1
String returns string representation of a trace state. The returned value is compatible with the `tracestate` header format. If the state has an Instana-specific list member, that one is always rendered first. This is optimized for the use case of injecting the string representation of the tracestate header into downstream requests.
type Version ¶ added in v1.12.1
type Version uint8
Version represents the W3C trace context version. It defines the format of `traceparent` header
func ParseVersion ¶ added in v1.12.1
ParseVersion parses the version part of a `traceparent` header value. It returns ErrContextCorrupted if the version is malformed
func (Version) String ¶ added in v1.12.1
String returns string representation of a trace parent version. The returned value is compatible with the `traceparent` header format. The caller should take care of handling the Version_Unknown, otherwise this method will return "ff" which is considered invalid