tracing

package
v0.0.0-...-be214e9 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitGlobalTracer

func InitGlobalTracer(name string, jaegerCfg *config.JaegerConfig) (io.Closer, error)

InitGlobalTracer creates a new Jaeger tracer, and sets it as global tracer.

func SetGlob

func SetGlob(t Tracer)

SetGlob sets the global tracer, for testing

Types

type JaegerTracer

type JaegerTracer struct {
	// contains filtered or unexported fields
}

JaegerTracer implements the Tracer interface using the jaeger client library

func (*JaegerTracer) InitGlobalTracer

func (t *JaegerTracer) InitGlobalTracer(name string, cfg *config.JaegerConfig) (io.Closer, error)

InitGlobalTracer creates a global tracer using the Jaeger client

func (*JaegerTracer) IsEnabled

func (*JaegerTracer) IsEnabled() bool

IsEnabled satisfies the Tracer interface, always returning true

func (JaegerTracer) StartSpanFromContext

func (t JaegerTracer) StartSpanFromContext(
	ctx context.Context,
	opName string,
) (opentracing.Span, context.Context)

StartSpanFromContext attempts to extract span info from the given context.Context and creates a new / child span accordingly, which is associated to the same context object.

func (JaegerTracer) StartSpanFromRequestHeader

func (t JaegerTracer) StartSpanFromRequestHeader(
	ctx context.Context,
	opName string,
	header http.Header,
) (opentracing.Span, context.Context)

StartSpanFromRequestHeader attempts to extract span info from the request header and creates a new / child span accordingly, which is associated to the given context.Context object.

type NopTracer

type NopTracer struct{}

NopTracer implements the Tracer interface with dummy methods

func (*NopTracer) InitGlobalTracer

func (*NopTracer) InitGlobalTracer(_ string, _ *config.JaegerConfig) (io.Closer, error)

InitGlobalTracer satisfies the Tracer interface and returns a Nop closer

func (*NopTracer) IsEnabled

func (*NopTracer) IsEnabled() bool

IsEnabled satisfies the Tracer interface, always returning false

func (*NopTracer) StartSpanFromContext

func (*NopTracer) StartSpanFromContext(
	ctx context.Context,
	_ string,
) (opentracing.Span, context.Context)

StartSpanFromContext satisfies the Tracer interface, returning the context as is and an empty span

func (*NopTracer) StartSpanFromRequestHeader

func (*NopTracer) StartSpanFromRequestHeader(
	ctx context.Context,
	_ string,
	_ http.Header,
) (opentracing.Span, context.Context)

StartSpanFromRequestHeader satisfies the Tracer interface, returning the context as is and an empty span

type Tracer

type Tracer interface {
	InitGlobalTracer(string, *config.JaegerConfig) (io.Closer, error)
	IsEnabled() bool
	StartSpanFromRequestHeader(
		context.Context,
		string,
		http.Header,
	) (opentracing.Span, context.Context)
	StartSpanFromContext(context.Context, string) (opentracing.Span, context.Context)
}

Tracer represents a generic tracer that supports initialization of a global tracing client and creation of opentracing spans

func Glob

func Glob() Tracer

Glob returns the global tracer

Jump to

Keyboard shortcuts

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