otel

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshallContext

func MarshallContext(ctx context.Context) ([]byte, error)

MarshallContext encodes the context to a JSON object. Assumes that there is an initialized context map propagator.

func UnmarshallContext

func UnmarshallContext(
	ctx context.Context,
	obj []byte,
) (context.Context, error)

UnmarshallContext decodes the JSON object into the given context. Assumes that there is an initialized context map propagator.

Types

type GlobalTracer

type GlobalTracer struct {
	trace.Tracer
}

func New

func New(opt *Options) (*GlobalTracer, error)

New connects to the collector and returns a new tracer.

func (*GlobalTracer) StartSpan added in v0.2.0

func (gt *GlobalTracer) 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 Operation error and returns it. Span.End does nothing if called more than one time.

type Operation added in v0.2.0

type Operation func(ctx context.Context, span trace.Span) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL