zipkin-go: Index | Files

package b3

import ""

Package b3 implements serialization and deserialization logic for Zipkin B3 Headers.


Package Files

doc.go grpc.go http.go map.go shared.go spancontext.go


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


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

func BuildSingleHeader Uses

func BuildSingleHeader(sc model.SpanContext) string

BuildSingleHeader takes the values from the SpanContext and builds the B3 header

func ExtractGRPC Uses

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 Uses

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 Uses

func GetGRPCHeader(md *metadata.MD, key string) string

GetGRPCHeader retrieves the last value found for a particular key. If key is not found it returns an empty string.

func InjectGRPC Uses

func InjectGRPC(md *metadata.MD) propagation.Injector

InjectGRPC will inject a span.Context into gRPC metadata.

func InjectHTTP Uses

func InjectHTTP(r *http.Request, opts ...InjectOption) propagation.Injector

InjectHTTP will inject a span.Context into a HTTP Request

func ParseHeaders Uses

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 Uses

func ParseSingleHeader(contextHeader string) (*model.SpanContext, error)

ParseSingleHeader takes values found from B3 Single Header and tries to reconstruct a SpanContext.

type InjectOption Uses

type InjectOption func(opts *InjectOptions)

func WithSingleAndMultiHeader Uses

func WithSingleAndMultiHeader() InjectOption

WithSingleAndMultiHeader allows to include both single and multiple headers in the context injection

func WithSingleHeaderOnly Uses

func WithSingleHeaderOnly() InjectOption

WithSingleHeaderOnly allows to include only single header in the context injection

type InjectOptions Uses

type InjectOptions struct {
    // contains filtered or unexported fields

type Map Uses

type Map map[string]string

Map allows serialization and deserialization of SpanContext into a standard Go map.

func (*Map) Extract Uses

func (m *Map) Extract() (*model.SpanContext, error)

Extract implements Extractor

func (*Map) Inject Uses

func (m *Map) Inject(opts ...InjectOption) propagation.Injector

Inject implements Injector

Package b3 imports 7 packages (graph) and is imported by 21 packages. Updated 2019-08-30. Refresh now. Tools for package owners.