Documentation ¶
Overview ¶
Package b3 implements serialization and deserialization logic for Zipkin B3 Headers.
Index ¶
- Constants
- Variables
- func BuildSingleHeader(sc model.SpanContext) string
- func ExtractGRPC(md *metadata.MD) propagation.Extractor
- func ExtractHTTP(r *http.Request) propagation.Extractor
- func GetGRPCHeader(md *metadata.MD, key string) string
- func InjectGRPC(md *metadata.MD) propagation.Injector
- func InjectHTTP(r *http.Request, opts ...InjectOption) propagation.Injector
- func ParseHeaders(hdrTraceID, hdrSpanID, hdrParentSpanID, hdrSampled, hdrFlags string) (*model.SpanContext, error)
- func ParseSingleHeader(contextHeader string) (*model.SpanContext, error)
- type InjectOption
- type InjectOptions
- type Map
Constants ¶
const ( TraceID = "x-b3-traceid" SpanID = "x-b3-spanid" ParentSpanID = "x-b3-parentspanid" Sampled = "x-b3-sampled" Flags = "x-b3-flags" Context = "b3" )
Default B3 Header keys
Variables ¶
var ( ErrInvalidSampledByte = errors.New("invalid B3 Sampled found") ErrInvalidSampledHeader = errors.New("invalid B3 Sampled header found") ErrInvalidFlagsHeader = errors.New("invalid B3 Flags header found") ErrInvalidTraceIDHeader = errors.New("invalid B3 TraceID header found") ErrInvalidSpanIDHeader = errors.New("invalid B3 SpanID header found") ErrInvalidParentSpanIDHeader = errors.New("invalid B3 ParentSpanID header found") ErrInvalidScope = errors.New("require either both TraceID and SpanID or none") ErrInvalidScopeParent = errors.New("ParentSpanID requires both TraceID and SpanID to be available") ErrInvalidScopeParentSingle = errors.New("ParentSpanID requires TraceID, SpanID and Sampled to be available") ErrEmptyContext = errors.New("empty request context") ErrInvalidTraceIDValue = errors.New("invalid B3 TraceID value found") ErrInvalidSpanIDValue = errors.New("invalid B3 SpanID value found") ErrInvalidParentSpanIDValue = errors.New("invalid B3 ParentSpanID value found") )
Common Header Extraction / Injection errors
Functions ¶
func BuildSingleHeader ¶ added in v0.1.7
func BuildSingleHeader(sc model.SpanContext) string
BuildSingleHeader takes the values from the SpanContext and builds the B3 header
func ExtractGRPC ¶
func ExtractGRPC(md *metadata.MD) propagation.Extractor
ExtractGRPC will extract a span.Context from the gRPC Request metadata if found in B3 header format.
func ExtractHTTP ¶
func ExtractHTTP(r *http.Request) propagation.Extractor
ExtractHTTP will extract a span.Context from the HTTP Request if found in B3 header format.
func GetGRPCHeader ¶
GetGRPCHeader retrieves the last value found for a particular key. If key is not found it returns an empty string.
func InjectGRPC ¶
func InjectGRPC(md *metadata.MD) propagation.Injector
InjectGRPC will inject a span.Context into gRPC metadata.
func InjectHTTP ¶
func InjectHTTP(r *http.Request, opts ...InjectOption) propagation.Injector
InjectHTTP will inject a span.Context into a HTTP Request
func ParseHeaders ¶
func ParseHeaders( hdrTraceID, hdrSpanID, hdrParentSpanID, hdrSampled, hdrFlags string, ) (*model.SpanContext, error)
ParseHeaders takes values found from B3 Headers and tries to reconstruct a SpanContext.
func ParseSingleHeader ¶ added in v0.1.7
func ParseSingleHeader(contextHeader string) (*model.SpanContext, error)
ParseSingleHeader takes values found from B3 Single Header and tries to reconstruct a SpanContext.
Types ¶
type InjectOption ¶ added in v0.1.7
type InjectOption func(opts *InjectOptions)
InjectOption provides functional option handler type.
func WithSingleAndMultiHeader ¶ added in v0.1.7
func WithSingleAndMultiHeader() InjectOption
WithSingleAndMultiHeader allows to include both single and multiple headers in the context injection
func WithSingleHeaderOnly ¶ added in v0.1.7
func WithSingleHeaderOnly() InjectOption
WithSingleHeaderOnly allows to include only single header in the context injection
type InjectOptions ¶ added in v0.1.7
type InjectOptions struct {
// contains filtered or unexported fields
}
InjectOptions provides the available functional options.
type Map ¶ added in v0.2.1
Map allows serialization and deserialization of SpanContext into a standard Go map.
func (*Map) Extract ¶ added in v0.2.1
func (m *Map) Extract() (*model.SpanContext, error)
Extract implements Extractor
func (*Map) Inject ¶ added in v0.2.1
func (m *Map) Inject(opts ...InjectOption) propagation.Injector
Inject implements Injector