tracing

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpNameBootstrap  = "bootstrap"
	OpNameStart      = "startup"
	OpNameStop       = "shutdown"
	OpNameHttp       = "http"
	OpNameRedis      = "redis"
	OpNameVault      = "vault"
	OpNameDB         = "db"
	OpNameCli        = "cli"
	OpNameHttpClient = "remote-http"
	OpNameSecScope   = "security"
	OpNameKafka      = "kafka"
	OpNameScheduler  = "scheduler"
)
View Source
const (
	TracingPropertiesPrefix = "tracing"
)

Variables

View Source
var TracingLogValuers = log.ContextValuers{
	"traceId":  traceIdContextValuer,
	"spanId":   spanIdContextValuer,
	"parentId": parentIdContextValuer,
}

Functions

func ContextWithSpanRewinder

func ContextWithSpanRewinder(ctx context.Context, finisher SpanRewinder) context.Context

func NewDefaultTracer

func NewDefaultTracer() (opentracing.Tracer, io.Closer)

func NewJaegerTracer

func NewJaegerTracer(ctx *bootstrap.ApplicationContext, jp *JaegerProperties, sp *SamplerProperties) (opentracing.Tracer, io.Closer)

func ParentIdFromContext

func ParentIdFromContext(ctx context.Context) (ret interface{})

func SpanFromContext

func SpanFromContext(ctx context.Context) (span opentracing.Span)

func SpanIdFromContext

func SpanIdFromContext(ctx context.Context) (ret interface{})

func TraceIdFromContext

func TraceIdFromContext(ctx context.Context) (ret interface{})

Types

type JaegerProperties

type JaegerProperties struct {
	Enabled bool   `json:"enabled"`
	Host    string `json:"host"`
	Port    int    `json:"port"`
}

type Option

type Option func(propagator *Propagator)

Option is a function that sets an option on Propagator

func BaggagePrefix

func BaggagePrefix(prefix string) Option

BaggagePrefix is a function that sets baggage prefix on Propagator

func SingleHeader

func SingleHeader() Option

type Propagator

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

Propagator is an extension of zipkin.Propagator that support Single Header propagation: See https://github.com/openzipkin/b3-propagation#single-header

func NewZipkinB3Propagator

func NewZipkinB3Propagator(opts ...Option) *Propagator

NewZipkinB3Propagator creates a Propagator for extracting and injecting Zipkin B3 headers into SpanContexts. Baggage is by default enabled and uses prefix 'baggage-'.

func (Propagator) Extract

func (p Propagator) Extract(abstractCarrier interface{}) (jaeger.SpanContext, error)

Extract conforms to the Extractor interface for encoding Zipkin HTTP B3 headers

func (Propagator) Inject

func (p Propagator) Inject(sc jaeger.SpanContext, abstractCarrier interface{}) error

Inject conforms to the Injector interface for decoding Zipkin B3 headers

type SamplerProperties

type SamplerProperties struct {
	Enabled     bool    `json:"enabled"`
	RateLimit   float64 `json:"limit-per-second"`
	Probability float64 `json:"probability"`
	LowestRate  float64 `json:"lowest-per-second"`
}

type SpanOperator

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

func WithTracer

func WithTracer(tracer opentracing.Tracer) *SpanOperator

func (SpanOperator) DescendantOrNoSpan

func (op SpanOperator) DescendantOrNoSpan(ctx context.Context) context.Context

DescendantOrNoSpan spawn a child span using opentracing.ChildOf(span.Context()) if there is a span exists otherwise do nothing

func (SpanOperator) Finish

func (op SpanOperator) Finish(ctx context.Context)

Finish finish current span if exist. Note: The finished span is still counted as "current span".

If caller want to rewind to previous span, use FinishAndRewind instead

func (SpanOperator) FinishAndRewind

func (op SpanOperator) FinishAndRewind(ctx context.Context) context.Context

FinishAndRewind finish current span if exist and restore context with parent span if possible (no garantees) callers shall not continue to use the old context after this call Note: all values in given context added during the current span will be lost. It's like rewind operation

func (SpanOperator) FollowsOrNoSpan

func (op SpanOperator) FollowsOrNoSpan(ctx context.Context) context.Context

FollowsOrNoSpan spawn a child span using opentracing.FollowsFrom(span.Context()) if there is a span exists otherwise do nothing

func (SpanOperator) ForceNewSpan

func (op SpanOperator) ForceNewSpan(ctx context.Context) context.Context

ForceNewSpan force to create a new span and discard any existing span Warning: Internal usage, use with caution

func (SpanOperator) NewSpanOrDescendant

func (op SpanOperator) NewSpanOrDescendant(ctx context.Context) context.Context

NewSpanOrDescendant create new span if not currently have one, spawn a child span using opentracing.ChildOf(span.Context()) if span exists

func (SpanOperator) NewSpanOrFollows

func (op SpanOperator) NewSpanOrFollows(ctx context.Context) context.Context

NewSpanOrDescendant create new span if not currently have one, spawn a child span using opentracing.FollowsFrom(span.Context()) if span exists

func (SpanOperator) UpdateCurrentSpan

func (op SpanOperator) UpdateCurrentSpan(ctx context.Context)

func (*SpanOperator) WithOpName

func (op *SpanOperator) WithOpName(name string) *SpanOperator

func (*SpanOperator) WithOptions

func (op *SpanOperator) WithOptions(exts ...SpanOption) *SpanOperator

func (*SpanOperator) WithStartOptions

func (op *SpanOperator) WithStartOptions(options ...opentracing.StartSpanOption) *SpanOperator

type SpanOption

type SpanOption func(opentracing.Span)

func SpanBaggageItem

func SpanBaggageItem(restrictedKey string, s string) SpanOption

func SpanComponent

func SpanComponent(v string) SpanOption

func SpanHttpMethod

func SpanHttpMethod(v string) SpanOption

func SpanHttpStatusCode

func SpanHttpStatusCode(v int) SpanOption

func SpanHttpUrl

func SpanHttpUrl(v string) SpanOption

func SpanKind

func SpanKind(v ext.SpanKindEnum) SpanOption

func SpanTag

func SpanTag(key string, v interface{}) SpanOption

type SpanRewinder

type SpanRewinder func() context.Context

func SpanRewinderFromContext

func SpanRewinderFromContext(ctx context.Context) SpanRewinder

type TracingProperties

type TracingProperties struct {
	Enabled bool              `json:"enabled"`
	Jaeger  JaegerProperties  `json:"jaeger"`
	Zipkin  ZipkinProperties  `json:"zipkin"`
	Sampler SamplerProperties `json:"sampler"`
}

func BindTracingProperties

func BindTracingProperties(ctx *bootstrap.ApplicationContext) TracingProperties

BindManagementProperties create and bind SessionProperties, with a optional prefix

func NewTracingProperties

func NewTracingProperties() *TracingProperties

NewSessionProperties create a SessionProperties with default values

type ZipkinProperties

type ZipkinProperties struct {
	Enabled bool `json:"enabled"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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