Documentation ¶
Index ¶
- Constants
- Variables
- type AMQPExtractor
- type AMQPInjector
- type Extractor
- type GooglePubSubExtractor
- type GooglePubSubInjector
- type HTTPExtractor
- type HTTPInjector
- type Span
- type SpanContext
- type TextMapExtractor
- type TextMapInjector
- type Tracer
- func (tracer *Tracer) Close() error
- func (tracer *Tracer) CurrentSpan() tracing.Span
- func (tracer *Tracer) EmptySpanContext() tracing.SpanContext
- func (tracer *Tracer) Extract(carrier interface{}, format string) (tracing.SpanContext, error)
- func (tracer *Tracer) Flush()
- func (tracer *Tracer) Inject(carrier interface{}, format string) error
- func (tracer *Tracer) InjectContext(carrier interface{}, format string, spanCtx tracing.SpanContext) error
- func (tracer *Tracer) RegisterExtractionFormat(format string, extractor tracing.Extractor)
- func (tracer *Tracer) RegisterInjectionFormat(format string, injector tracing.Injector)
- func (tracer *Tracer) RootSpan() tracing.Span
- func (tracer *Tracer) StartSpan(name string, spanCtx tracing.SpanContext) tracing.Span
- func (tracer *Tracer) UUID() string
- type TracerOptions
- type TracerSetter
Constants ¶
const ( // MaxTagLen controls the maximum size of tag value in bytes MaxTagLen = 1048576 // DefaultRequestTimeout sets maximum timeout for http request to send spans DefaultRequestTimeout = time.Second * 5 )
Variables ¶
var ( // ErrCollectorIPNotFound is returned if you used hostname in place of collector IP // and we weren't able to resolve the valid address from it ErrCollectorIPNotFound = errors.New("unable to resolve collector's IP address") )
Functions ¶
This section is empty.
Types ¶
type AMQPExtractor ¶
type AMQPExtractor struct {
TracerSetter
}
AMQPExtractor manages trace extraction from AMQP carrier
func NewAMQPExtractor ¶
func NewAMQPExtractor() *AMQPExtractor
NewAMQPExtractor returns the instance of AMQPExtractor
func (*AMQPExtractor) Extract ¶
func (extractor *AMQPExtractor) Extract(carrier interface{}) (tracing.SpanContext, error)
Extract deserializes SpanContext from amqp.Delivery object
type AMQPInjector ¶
type AMQPInjector struct { }
AMQPInjector manages trace injection into AMQP carrier
func NewAMQPInjector ¶
func NewAMQPInjector() *AMQPInjector
NewAMQPInjector returns the instance of AMQPInjector
func (*AMQPInjector) Inject ¶
func (extractor *AMQPInjector) Inject(spanCtx tracing.SpanContext, carrier interface{}) error
Inject serialises given SpanContext into given amqp.Publishing object
type Extractor ¶
type Extractor interface { Extract(carrier interface{}) (tracing.SpanContext, error) SetTracing(tracer *openzipkin.Tracer) }
Extractor is used to assert that the extractor implements SetTracing method
type GooglePubSubExtractor ¶ added in v0.5.0
type GooglePubSubExtractor struct {
TracerSetter
}
GooglePubSubExtractor manages trace extraction from Google PubSub carrier
func NewGooglePubSubExtractor ¶ added in v0.5.0
func NewGooglePubSubExtractor() *GooglePubSubExtractor
NewGooglePubSubExtractor returns the instance of AMQPExtractor
func (*GooglePubSubExtractor) Extract ¶ added in v0.5.0
func (extractor *GooglePubSubExtractor) Extract(carrier interface{}) (tracing.SpanContext, error)
Extract deserializes SpanContext from amqp.Delivery object
type GooglePubSubInjector ¶ added in v0.5.0
type GooglePubSubInjector struct { }
GooglePubSubInjector manages trace injection into Google Cloud PubSub carrier
func NewGooglePubSubInjector ¶ added in v0.5.0
func NewGooglePubSubInjector() *GooglePubSubInjector
NewGooglePubSubInjector returns the instance of GooglePubSubInjector
func (*GooglePubSubInjector) Inject ¶ added in v0.5.0
func (extractor *GooglePubSubInjector) Inject(spanCtx tracing.SpanContext, carrier interface{}) error
Inject serialises given SpanContext into given amqp.Publishing object
type HTTPExtractor ¶
type HTTPExtractor struct {
TracerSetter
}
HTTPExtractor manages trace extraction from HTTP carrier
func NewHTTPExtractor ¶
func NewHTTPExtractor() *HTTPExtractor
NewHTTPExtractor returns the instance of HTTPExtractor
func (*HTTPExtractor) Extract ¶
func (extractor *HTTPExtractor) Extract(carrier interface{}) (tracing.SpanContext, error)
Extract deserializes SpanContext from http.Request object
type HTTPInjector ¶
type HTTPInjector struct { }
HTTPInjector manages trace injection into HTTP carrier
func NewHTTPInjector ¶
func NewHTTPInjector() *HTTPInjector
NewHTTPInjector returns the instance of HTTPInjector
func (*HTTPInjector) Inject ¶
func (extractor *HTTPInjector) Inject(spanCtx tracing.SpanContext, carrier interface{}) error
Inject serialises given SpanContext into a given http.Request object
type Span ¶
type Span struct {
// contains filtered or unexported fields
}
Span encapsulates the state of logical operation it represents
func (*Span) Context ¶
func (span *Span) Context() tracing.SpanContext
Context retrieves SpanContext for this Span
func (*Span) Finish ¶
func (span *Span) Finish()
Finish notifies that operation has finished. Span duration is derived by subtracting the start timestamp from this, and set when appropriate.
func (*Span) Log ¶
Log stores structured data. Despite this functionality being outlined in OpenTracing spec it's currently only supported in Jaeger
type SpanContext ¶
type SpanContext struct {
// contains filtered or unexported fields
}
SpanContext holds the context of a Span. It should be initialized using NewSpanContext method.
func NewSpanContext ¶
func NewSpanContext(rawCtx interface{}) *SpanContext
NewSpanContext returns a new SpanContext
func (*SpanContext) RawContext ¶
func (spanCtx *SpanContext) RawContext() interface{}
RawContext returns underlying (original) span context.
type TextMapExtractor ¶
type TextMapExtractor struct {
TracerSetter
}
TextMapExtractor manages trace extraction from TextMap carrier
func NewTextMapExtractor ¶
func NewTextMapExtractor() *TextMapExtractor
NewTextMapExtractor returns the instance of TextMapExtractor
func (*TextMapExtractor) Extract ¶
func (extractor *TextMapExtractor) Extract(carrier interface{}) (tracing.SpanContext, error)
Extract deserializes SpanContext from a map
type TextMapInjector ¶
type TextMapInjector struct { }
TextMapInjector manages trace injection into TextMap carrier
func NewTextMapInjector ¶
func NewTextMapInjector() *TextMapInjector
NewTextMapInjector returns the instance of TextMapInjector
func (*TextMapInjector) Inject ¶
func (extractor *TextMapInjector) Inject(spanCtx tracing.SpanContext, carrier interface{}) error
Inject serialises given SpanContext into a given map
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
Tracer is the tracing implementation for Zipkin. It should be initialized using NewTracer method.
func NewTracer ¶
func NewTracer(opt TracerOptions) (*Tracer, error)
NewTracer returns a new Zipkin tracer.
func (*Tracer) Close ¶
Close does a clean shutdown of the reporter, sending any traces that may be buffered in memory. This is especially useful for command-line tools that enable tracing, as well as for the long-running apps that support graceful shutdown.
It goes without saying, but you cannot send anymore spans after calling Close, so you should only run this once during the lifecycle of the program.
func (*Tracer) CurrentSpan ¶
func (tracer *Tracer) CurrentSpan() tracing.Span
CurrentSpan retrieves the most recently activated span.
func (*Tracer) EmptySpanContext ¶
func (tracer *Tracer) EmptySpanContext() tracing.SpanContext
EmptySpanContext return empty span context for creating spans
func (*Tracer) Extract ¶
Extract deserializes span context from from a given carrier using the format descriptor that tells tracer how to decode it from the carrier parameters
func (*Tracer) Flush ¶
func (tracer *Tracer) Flush()
Flush may flush any pending spans to the transport and reset the state of the tracer. Make sure this method is always called after the request is finished.
func (*Tracer) Inject ¶
Inject implicitly serializes current span context using the format descriptor that tells how to encode trace info in the carrier parameters
func (*Tracer) InjectContext ¶
func (tracer *Tracer) InjectContext(carrier interface{}, format string, spanCtx tracing.SpanContext) error
InjectContext serializes specified span context into a given carrier using the format descriptor that tells how to encode trace info in the carrier parameters
func (*Tracer) RegisterExtractionFormat ¶
RegisterExtractionFormat register extractor implementation for given format string
func (*Tracer) RegisterInjectionFormat ¶
RegisterInjectionFormat register injector implementation for given format string
func (*Tracer) RootSpan ¶
func (tracer *Tracer) RootSpan() tracing.Span
RootSpan retrieves the root span of the service
func (*Tracer) StartSpan ¶
StartSpan starts a new span based on a parent trace context. The context may come either from external source (extracted from HTTP request, AMQP message, etc., see Extract method) or received from another span in the service.
If parent context does not contain a trace, a new trace will be implicitly created. Use EmptySpanContext to supply empty (nil) context.
type TracerOptions ¶
type TracerOptions struct { // ServiceName is the name of application you're tracing // Required ServiceName string // Host // Required Host string // Port // Required Port string // UsesTraceID128Bit tells whether to use 128 bit trace IDs (32 characters in length as opposed to 16) // Defaults to false UsesTraceID128Bit bool // Reporter option allows to inject your own reporter for tests // Defaults to http reporter Reporter reporter.Reporter // Timeout sets maximum timeout for http request to send spans // Setting this to a too high value is not recommended because it // may degrade your system performance when collector is down. // Note that reporter will re-try after the first failure. // See this issue for more details: https://github.com/openzipkin/zipkin-go/issues/147 RequestTimeout time.Duration }
TracerOptions is a configuration container to setup the Tracer.
type TracerSetter ¶
type TracerSetter struct { tracing.Extractor Tracing *openzipkin.Tracer }
TracerSetter is supposed to be embedded in every Zipkin extractor to provide access to underlying Zipkin tracer instance
func (*TracerSetter) SetTracing ¶
func (embedding *TracerSetter) SetTracing(tracer *openzipkin.Tracer)
SetTracing sets the instance of Zipkin tracer (from the underlying instrumnetation) on the embedding type