Documentation ¶
Overview ¶
Package tracing is a streamlined distributed tracing solution that roughly follows an OpenTracing spec.
Currently, Zipkin and Noop drivers are available out of the box with propagation methods for TextMap, HTTP and AMQP formats.
For a full guide visit https://github.com/Vinelab/tracing-go
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Extractor ¶
type Extractor interface { // Extract deserializes span context from given carrier Extract(carrier interface{}) (SpanContext, error) }
Extractor interface can be used to provide the Tracer with custom implementations to deserialize data from a given carrier
type Injector ¶
type Injector interface { // Inject serializes span context into given carrier Inject(spanCtx SpanContext, carrier interface{}) error }
Injector interface can be used to provide the Tracer with custom implementations to serialize data into a given carrier
type Span ¶
type Span interface { // SetName sets (overrides) the string name for the logical operation this span represents. SetName(name string) // Tag give your span context for search, viewing and analysis. For example, // a key "your_app.version" would let you lookup spans by version. Tag(key string, value string) // Finish notifies that operation has finished. Span duration is derived by subtracting the start // timestamp from this, and set when appropriate. Finish() // Annotate associates an event that explains latency with a timestamp. Annotate(message string) // Log stores structured data. Despite this functionality being outlined in // OpenTracing spec it's currently only supported in Jaeger Log(fields map[string]string) // IsRoot tells whether the span is a root span IsRoot() bool // Context retrieves SpanContext for this Span Context() SpanContext }
Span interface is returned by Tracer.StartSpan(). You can use it to provide your own custom implementation
type SpanContext ¶
type SpanContext interface {
// RawContext returns underlying (original) span context.
RawContext() interface{}
}
type Tracer ¶
type Tracer interface { // 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. StartSpan(name string, spanCtx SpanContext) Span // RootSpan retrieves the root span of the service RootSpan() Span // CurrentSpan retrieves the most recently activated span. CurrentSpan() Span // UUID retrieves unique identifier associated with a root span UUID() string // EmptySpanContext return empty span context for creating spans EmptySpanContext() SpanContext // Extract deserializes span context from from a given carrier using the format descriptor // that tells tracer how to decode it from the carrier parameters Extract(carrier interface{}, format string) (SpanContext, error) // Inject implicitly serializes current span context using the format descriptor that // tells how to encode trace info in the carrier parameters Inject(carrier interface{}, format string) 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 InjectContext(carrier interface{}, format string, spanCtx SpanContext) error // RegisterExtractionFormat register extractor implementation for given format string RegisterExtractionFormat(format string, extractor Extractor) // RegisterInjectionFormat register injector implementation for given format string RegisterInjectionFormat(format string, injector Injector) // 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. Flush() // 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. Close() error }
Tracer interface can be used to create your own tracing driver that wraps a lower level instrumentation
type UnregisteredFormatError ¶
type UnregisteredFormatError struct {
// contains filtered or unexported fields
}
UnregisteredFormatError is returned when you tried to inject/extract trace context using unregistered format or when there is a mismatch between format and extractor
func NewUnregisteredFormatError ¶
func NewUnregisteredFormatError(err string, format string) *UnregisteredFormatError
NewUnregisteredFormatError returns instance of UnregisteredFormatError
func (*UnregisteredFormatError) Error ¶
func (e *UnregisteredFormatError) Error() string
Error returns the string representation of the error