Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSpanID ¶
func GetSpanID(span opentracing.Span) string
GetSpanID extracts the span ID from the opentracing Span.
Currently only jaeger is supported. This can be useful when paired with the latest Grafana that includes a trace viewer.
func GetTraceID ¶
func GetTraceID(span opentracing.Span) string
GetTraceID extracts the span ID from the opentracing Span.
Currently only jaeger is supported. This can be useful when paired with the latest Grafana that includes a trace viewer.
func InitJaeger ¶
InitJaeger asserts that the global tracer is initialized.
This will read the configuration from the "JAEGER_*"" environment variables. Overriding the empty values with the supplied app value. If a sampler type is not configured via the environment variables, then InitJaeger will be configured with the constant sampler.
Types ¶
type SpanHook ¶
type SpanHook struct{}
SpanHook is a logrus Hook to send write logs and their fields to the current span.
type Tracer ¶
type Tracer interface { StartSpan(ctx context.Context, operationName string) (opentracing.Span, context.Context) FinishSpan(opentracing.Span, error) }
Tracer contains all the tracing-related functions for any module of the server that uses tracing
Normally, if you have a module that needs tracing you embed the Tracer as following:
type Some struct { tracing.Tracer }
And then initialize the tracer when you initialize the module:
func NewSome() Some { return Some{ Tracer: tracing.NewTracer("package", "Some"), } }
To use the tracing capabilities you use it as following:
func (s Some) Foo(ctx context.Context) (err error) { span, ctx := s.StartSpan(ctx, "Foo") // since the err is not assigned yet we have to take it into the closure defer func() { s.FinishSpan(span, err) }() span.SetTag("something", "important") ... }
func NewTracer ¶
NewTracer create a new tracer that contains implementation for all tracing-related actions
func NewTracerWithLogs ¶
NewTracerWithLogs create a new tracer that contains logs spans to stdout as well as to the opentracing tracer.