Documentation
¶
Index ¶
- func GlobalTracer() trace.Tracer
- func MarshallContext(ctx context.Context) ([]byte, error)
- func Setup(opt *Options) error
- func StartSpan(ctx context.Context, name string, fn Operation, opts ...trace.SpanStartOption) (err error)
- func UnmarshallContext(ctx context.Context, obj []byte) (context.Context, error)
- type Operation
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GlobalTracer ¶
GlobalTracer returns the global tracer. If Setup wasn't called, the function returns a default tracer.
This function isn't thread safe which means that if it's called at the same time that Setup is creating the global tracer, this result in a race condition. Besides that, this isn't secured since the access to the tracer doesn't need to be thread locked.
func MarshallContext ¶
MarshallContext encodes the context to a JSON object. Assumes that there is an initialized context map propagator.
func Setup ¶ added in v1.1.0
Setup initializes the opentelemetry sdk and creates a global tracer which can be access with GlobalTracer. Does nothing on future calls.
func StartSpan ¶ added in v1.2.0
func StartSpan( ctx context.Context, name string, fn Operation, opts ...trace.SpanStartOption, ) (err error)
StartSpan creates a span arround a given operation. The function automatically closes the span, records the error returned by Operation (if any) and rereturns it. Span.End has no effect if called more than one time.
Types ¶
type Operation ¶ added in v0.2.0
Operation represents the execution wrapped by a span. The ctx parameter contains the context tied to the span. The returned error will be recorded in span and re-returned by StartSpan.
type Options ¶
type Options struct { ServiceName string TracerName string // CollectorAddr contains the grpc collector // address in the form <ip/domain>:<port>. CollectorAddr string // DialDeadline is the max time to dial // a connection with the collector. DialDeadline time.Duration }
Options contains all basic elements to establish a connection with an OpenTelemetry cluster.