Documentation ¶
Overview ¶
Package tracer provides an interface for distributed tracing
Package tracer provides an interface for distributed tracing
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultTracer = NewTracer()
DefaultTracer is the global default tracer
Functions ¶
func NewContext ¶
NewContext saves the tracer in the context
Types ¶
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
type Span ¶
type Span interface { // Tracer return underlining tracer Tracer() Tracer // Finish complete and send span Finish(opts ...SpanOption) // AddEvent add event to span AddEvent(name string, opts ...EventOption) // 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) // SetLabels set the span labels SetLabels(labels ...interface{}) // AddLabels append the span labels AddLabels(labels ...interface{}) // Kind returns span kind Kind() SpanKind }
type SpanKind ¶ added in v3.10.3
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 SpanOption ¶
type SpanOption func(o *SpanOptions)
SpanOption func signature
func WithSpanKind ¶ added in v3.10.3
func WithSpanKind(k SpanKind) SpanOption
func WithSpanLabels ¶ added in v3.10.3
func WithSpanLabels(labels ...interface{}) SpanOption
type SpanOptions ¶
type SpanOptions struct { Labels []interface{} Kind SpanKind }
SpanOptions contains span option
func NewSpanOptions ¶ added in v3.10.3
func NewSpanOptions(opts ...SpanOption) SpanOptions
NewSpanOptions returns default SpanOptions
type SpanStatus ¶ added in v3.10.4
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 ¶ added in v3.10.4
func (s SpanStatus) String() string
type Tracer ¶
type Tracer interface { // Name return tracer name Name() string // Init tracer with options Init(...Option) error // Start a trace Start(ctx context.Context, name string, opts ...SpanOption) (context.Context, Span) }
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.