Documentation ¶
Overview ¶
Package tracer provides an interface for distributed tracing
Package tracer provides an interface for distributed tracing
Index ¶
- Variables
- func NewContext(ctx context.Context, tracer Tracer) context.Context
- func NewSpanContext(ctx context.Context, span Span) context.Context
- func WithEventLabels(ls ...interface{}) options.Option
- func WithSpanKind(k SpanKind) options.Option
- func WithSpanLabels(ls ...interface{}) options.Option
- type EventOption
- type EventOptions
- type Options
- type Span
- type SpanKind
- type SpanOptions
- type SpanStatus
- type Tracer
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // TraceIDKey is the key used for the trace id in the log call TraceIDKey = "trace-id" // SpanIDKey is the key used for the span id in the log call SpanIDKey = "span-id" )
View Source
var DefaultTracer = NewTracer()
DefaultTracer is the global default tracer
Functions ¶
func NewContext ¶
NewContext saves the tracer in the context
func NewSpanContext ¶
NewSpanContext saves the span in the context
func WithEventLabels ¶ added in v4.0.8
func WithSpanKind ¶
func WithSpanLabels ¶
Types ¶
type EventOptions ¶
type EventOptions struct {
Labels []interface{}
}
EventOptions contains event options
func NewEventOptions ¶ added in v4.0.11
func NewEventOptions(opts ...options.Option) EventOptions
NewEventOptions returns default EventOptions
type Options ¶
type Options struct { // Context used to store custome tracer options Context context.Context // Logger used for logging Logger logger.Logger // Name of the tracer Name string }
Options struct
func NewOptions ¶
NewOptions returns default options
type Span ¶
type Span interface { // Tracer return underlining tracer Tracer() Tracer // Finish complete and send span Finish(opts ...options.Option) // Context return context with span Context() context.Context // SetName set the span name SetName(name string) // SetStatus set the span status code and msg SetStatus(status SpanStatus, msg string) // Status returns span status and msg Status() (SpanStatus, string) // AddLabels append labels to span AddLabels(kv ...interface{}) // AddEvent append event to span AddEvent(name string, opts ...options.Option) // AddLogs append logs to span AddLogs(kv ...interface{}) // Kind returns span kind Kind() SpanKind // TraceID returns trace id TraceID() string // SpanID returns span id SpanID() string }
type SpanKind ¶
type SpanKind int
const ( // SpanKindUnspecified is an unspecified SpanKind and is not a valid // SpanKind. SpanKindUnspecified should be replaced with SpanKindInternal // if it is received. SpanKindUnspecified SpanKind = 0 // SpanKindInternal is a SpanKind for a Span that represents an internal // operation within an application. SpanKindInternal SpanKind = 1 // SpanKindServer is a SpanKind for a Span that represents the operation // of handling a request from a client. SpanKindServer SpanKind = 2 // SpanKindClient is a SpanKind for a Span that represents the operation // of client making a request to a server. SpanKindClient SpanKind = 3 // SpanKindProducer is a SpanKind for a Span that represents the operation // of a producer sending a message to a message broker. Unlike // SpanKindClient and SpanKindServer, there is often no direct // relationship between this kind of Span and a SpanKindConsumer kind. A // SpanKindProducer Span will end once the message is accepted by the // message broker which might not overlap with the processing of that // message. SpanKindProducer SpanKind = 4 // SpanKindConsumer is a SpanKind for a Span that represents the operation // of a consumer receiving a message from a message broker. Like // SpanKindProducer Spans, there is often no direct relationship between // this Span and the Span that produced the message. SpanKindConsumer SpanKind = 5 )
type SpanOptions ¶
type SpanOptions struct { Labels []interface{} Kind SpanKind }
SpanOptions contains span option
func NewSpanOptions ¶
func NewSpanOptions(opts ...options.Option) SpanOptions
NewSpanOptions returns default SpanOptions
type SpanStatus ¶
type SpanStatus int
const ( // SpanStatusUnset is the default status code. SpanStatusUnset SpanStatus = 0 // SpanStatusError indicates the operation contains an error. SpanStatusError SpanStatus = 1 // SpanStatusOK indicates operation has been validated by an Application developers // or Operator to have completed successfully, or contain no error. SpanStatusOK SpanStatus = 2 )
func (SpanStatus) String ¶
func (s SpanStatus) String() string
type Tracer ¶
type Tracer interface { // Name return tracer name Name() string // Init tracer with options Init(...options.Option) error // Start a trace Start(ctx context.Context, name string, opts ...options.Option) (context.Context, Span) // Flush flushes spans Flush(ctx context.Context) error }
Tracer is an interface for distributed tracing
func FromContext ¶
FromContext returns a tracer from context
Click to show internal directories.
Click to hide internal directories.