tracing

package
v16.8.3 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiscardSpanInContext

func DiscardSpanInContext(ctx context.Context) context.Context

DiscardSpanInContext discards the current active span from the context. This function is helpful when the current code path enters an area shared by other code paths. Git catfile cache is a good example of this type of span.

func ExtractSpanContextFromEnv

func ExtractSpanContextFromEnv(envs []string) (opentracing.SpanContext, error)

ExtractSpanContextFromEnv extracts a SpanContext from the environment variable list. The caller usually passes the result of os.Environ() into this method.

func IsSampled

func IsSampled(ctx context.Context) bool

IsSampled tells whether a span belongs to a sampled trace

func StartSpan

func StartSpan(ctx context.Context, spanName string, tags Tags, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context)

StartSpan creates a new span with name and options (mostly tags). This function is a wrapper for underlying tracing libraries. This method should only be used at the entrypoint of the program.

func StartSpanIfHasParent

func StartSpanIfHasParent(ctx context.Context, spanName string, tags Tags, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context)

StartSpanIfHasParent creates a new span if the context already has an existing span. This function adds a simple validation to prevent orphan spans outside interested code paths. It returns a dummy span, which acts as normal span, but does absolutely nothing and is not recorded later.

func StreamPassthroughInterceptor

func StreamPassthroughInterceptor(spanContext opentracing.SpanContext) grpc.StreamClientInterceptor

StreamPassthroughInterceptor is equivalent to UnaryPassthroughInterceptor, but for streaming gRPC calls.

func UnaryPassthroughInterceptor

func UnaryPassthroughInterceptor(spanContext opentracing.SpanContext) grpc.UnaryClientInterceptor

UnaryPassthroughInterceptor is a client gRPC unary interceptor that rewrites a span context into the outgoing metadata of the call. It is useful for intermediate systems who don't want to start new spans.

Types

type NoopSpan

type NoopSpan struct{}

NoopSpan is a dummy span implementing opentracing.Span interface. All data setting functions do nothing. Data getting functions return other dummy objects. Spans of this kind are not recorded later.

func (*NoopSpan) BaggageItem

func (s *NoopSpan) BaggageItem(string) string

func (*NoopSpan) Context

func (s *NoopSpan) Context() opentracing.SpanContext

func (*NoopSpan) Finish

func (s *NoopSpan) Finish()

func (*NoopSpan) FinishWithOptions

func (s *NoopSpan) FinishWithOptions(_ opentracing.FinishOptions)

func (*NoopSpan) Log

func (s *NoopSpan) Log(opentracing.LogData)

func (*NoopSpan) LogEvent

func (s *NoopSpan) LogEvent(string)

func (*NoopSpan) LogEventWithPayload

func (s *NoopSpan) LogEventWithPayload(string, interface{})

func (*NoopSpan) LogFields

func (s *NoopSpan) LogFields(...log.Field)

func (*NoopSpan) LogKV

func (s *NoopSpan) LogKV(...interface{})

func (*NoopSpan) SetBaggageItem

func (s *NoopSpan) SetBaggageItem(string, string) opentracing.Span

func (*NoopSpan) SetOperationName

func (s *NoopSpan) SetOperationName(string) opentracing.Span

func (*NoopSpan) SetTag

func (s *NoopSpan) SetTag(string, interface{}) opentracing.Span

func (*NoopSpan) Tracer

func (s *NoopSpan) Tracer() opentracing.Tracer

type NoopSpanContext

type NoopSpanContext struct{}

NoopSpanContext is a dummy context returned by NoopSpan

func (NoopSpanContext) ForeachBaggageItem

func (n NoopSpanContext) ForeachBaggageItem(func(k string, v string) bool)

type NoopTracer

type NoopTracer struct{}

NoopTracer is a dummy tracer returned by NoopSpan

func (NoopTracer) Extract

func (n NoopTracer) Extract(interface{}, interface{}) (opentracing.SpanContext, error)

func (NoopTracer) Inject

func (n NoopTracer) Inject(opentracing.SpanContext, interface{}, interface{}) error

func (NoopTracer) StartSpan

func (n NoopTracer) StartSpan(string, ...opentracing.StartSpanOption) opentracing.Span

type Tags

type Tags map[string]any

Tags is a key-value map. It is used to set tags for a span

Jump to

Keyboard shortcuts

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