Documentation ¶
Index ¶
Constants ¶
const ( B3SingleHeader = "X-B3" B3DebugFlagHeader = "X-B3-Flags" B3TraceIDHeader = "X-B3-TraceId" B3SpanIDHeader = "X-B3-SpanId" B3SampledHeader = "X-B3-Sampled" B3ParentSpanIDHeader = "X-B3-ParentSpanId" )
Variables ¶
var ( //ServiceName is a trace attribute for the service name ServiceName = key.New("service.name") //EmptyParentSpanDescriptor is a descritor for an empty span EmptyParentSpanDescriptor = ParentSpanDescriptor{} )
var ( //ClientName is a trace attribute for the service name ClientName = key.New("client.name") )
Functions ¶
Types ¶
type B3 ¶ added in v0.0.7
type B3 struct {
SingleHeader bool
}
B3 propagator serializes core.SpanContext to/from B3 Headers. This propagator supports both version of B3 headers,
- Single Header : X-B3: {TraceId}-{SpanId}-{SamplingState}-{ParentSpanId}
- Multiple Headers: X-B3-TraceId: {TraceId} X-B3-ParentSpanId: {ParentSpanId} X-B3-SpanId: {SpanId} X-B3-Sampled: {SamplingState} X-B3-Flags: {DebugFlag}
If SingleHeader is set to true then X-B3 header is used to inject and extract. Otherwise, separate headers are used to inject and extract.
func (B3) Extract ¶ added in v0.0.7
func (b3 B3) Extract(ctx context.Context, supplier Supplier) (core.SpanContext, distributedcontext.Map)
Extract retrieves B3 Headers from the supplier
func (B3) GetAllKeys ¶ added in v0.0.7
type ClientTraceOption ¶
type ClientTraceOption func(*ClientTraceOptions)
ClientTraceOption
func WithClientTracer ¶
func WithClientTracer(tr trace.Tracer) ClientTraceOption
WithClientTracer sets a specific tracer to be uses
type ClientTraceOptions ¶
type ClientTraceOptions struct {
// contains filtered or unexported fields
}
ClientTraceOptions
type ClientTracer ¶
type ClientTracer interface { Inject(ctx context.Context, r *http.Request) (context.Context, *http.Request) StartSpan(ctx context.Context, spanName string, attrs []core.KeyValue, opts ...trace.StartOption) (context.Context, trace.Span) EndSpan(span trace.Span) }
ClientTracer allows tracing of blaze services
func NewClientTracer ¶
func NewClientTracer(opts ...ClientTraceOption) ClientTracer
NewClientTracer creates a new tracer
type ParentSpanDescriptor ¶
type ParentSpanDescriptor struct {
// contains filtered or unexported fields
}
ParentSpanDescriptor dexcribes the parent span
type ServiceTraceOption ¶
type ServiceTraceOption func(*ServiceTraceOptions)
ServiceTraceOption
func WithTracer ¶
func WithTracer(tr trace.Tracer) ServiceTraceOption
WithTracer sets a specific tracer to be uses
type ServiceTraceOptions ¶
type ServiceTraceOptions struct {
// contains filtered or unexported fields
}
ServiceTraceOptions
type ServiceTracer ¶
type ServiceTracer interface { Extract(r *http.Request) (context.Context, *http.Request, ParentSpanDescriptor) StartSpan(ctx context.Context, spanName string, psd ParentSpanDescriptor, attrs []core.KeyValue, opts ...trace.StartOption) (context.Context, trace.Span) EndSpan(span trace.Span) }
ServiceTracer allows tracing of blaze services
func NewServiceTracer ¶
func NewServiceTracer(opts ...ServiceTraceOption) ServiceTracer
NewServiceTracer
type Supplier ¶ added in v0.0.7
Supplier is an interface that specifies methods to retrieve and store value for a key to an associated carrier. Get method retrieves the value for a given key. Set method stores the value for a given key.
type TextFormat ¶ added in v0.0.7
type TextFormat interface { // Inject method retrieves current SpanContext from the ctx, encodes it into propagator // specific format and then injects the encoded SpanContext using supplier into a carrier // associated with the supplier. It also takes a correlationCtx whose values will be // injected into a carrier using the supplier. Inject(ctx context.Context, supplier Supplier) // Extract method retrieves encoded SpanContext using supplier from the associated carrier. // It decodes the SpanContext and returns it and a baggage of correlated context. // If no SpanContext was retrieved OR if the retrieved SpanContext is invalid then // an empty SpanContext is returned. Extract(ctx context.Context, supplier Supplier) (core.SpanContext, distributedcontext.Map) // GetAllKeys returns all the keys that this propagator injects/extracts into/from a // carrier. The use cases for this are // * allow pre-allocation of fields, especially in systems like gRPC Metadata // * allow a single-pass over an iterator (ex OpenTracing has no getter in TextMap) GetAllKeys() []string }
TextFormat is an interface that specifies methods to inject and extract SpanContext and distributed context into/from a carrier using Supplier interface. For example, HTTP Trace Context propagator would encode SpanContext into W3C Trace Context Header and set the header into HttpRequest.