tracing

package
v0.0.0-...-d6fd5ef Latest Latest
Warning

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

Go to latest
Published: May 31, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package tracing provides wrappers around opentracing's golang library to make them easier to use in Istio.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentSpan

func CurrentSpan(ctx context.Context) ot.Span

CurrentSpan extracts the current span from the context, or returns a no-op span if no span exists in the context. This avoids boilerplate nil checking when calling opentracing.SpanFromContext.

func IORecorder

func IORecorder(w io.Writer) bt.SpanRecorder

IORecorder returns a SpanRecorder which writes its spans to the provided io.Writer.

func LoggingRecorder

func LoggingRecorder() bt.SpanRecorder

LoggingRecorder returns a SpanRecorder which logs writes its spans to glog.

func NewContext

func NewContext(ctx context.Context, carrier *AttributeCarrier) context.Context

NewContext annotates the provided context with the provided carrier and returns the updated context.

func RootSpan

func RootSpan(ctx context.Context) ot.Span

RootSpan retrieves the root span from the context. This may be different than the current context returned by opentracing.SpanFromContext(ctx)

Types

type AttributeCarrier

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

AttributeCarrier implements opentracing's TextMapWriter and TextMapReader interfaces using Istio's attribute system.

func FromContext

func FromContext(ctx context.Context) *AttributeCarrier

FromContext extracts the AttributeCarrier from the provided context, or returns nil if one is not found.

func NewCarrier

func NewCarrier(bag *attribute.MutableBag) *AttributeCarrier

NewCarrier initializes a carrier that can be used to modify the attributes in the current request context.

func (*AttributeCarrier) ForeachKey

func (c *AttributeCarrier) ForeachKey(handler func(key, val string) error) error

ForeachKey iterates over the keys that correspond to string attributes, filtering keys for the prefix used by the AttributeCarrier to denote opentracing attributes. The AttributeCarrier specific prefix is stripped from the key before its passed to handler.

func (*AttributeCarrier) Set

func (c *AttributeCarrier) Set(key, val string)

Set adds (key, val) to the set of string attributes in the request scope. It prefixes the key with an istio-private string to avoid collisions with other attributes when arbitrary tracer implementations are used.

type Tracer

type Tracer struct {
	ot.Tracer
	// contains filtered or unexported fields
}

Tracer wraps an opentracing.Tracer with a flag that's enabled when tracing is enabled. This flag is used to short-circuit methods that may be costly (intercepting client calls, propagating span metadata, etc). The tracer's methods will always return objects that are safe to work with, e.g. if tracing is disabled and StartRootSpan is called, a no-op span will be returned, not nil.

func DisabledTracer

func DisabledTracer() Tracer

DisabledTracer disables tracing, letting methods in tracing.go short-circuit.

func NewTracer

func NewTracer(tracer ot.Tracer) Tracer

NewTracer wraps the provided tracer and enables tracing.

func (*Tracer) PropagateSpan

func (t *Tracer) PropagateSpan(ctx context.Context, span ot.Span) (metadata.MD, context.Context)

PropagateSpan inserts metadata about the span into the context's metadata so that the span is propagated to the receiver. This should be used to prepare the context for outgoing calls.

func (*Tracer) StartRootSpan

func (t *Tracer) StartRootSpan(ctx context.Context, operationName string, opts ...ot.StartSpanOption) (ot.Span, context.Context)

StartRootSpan creates a span that is the root of all Istio spans in the current request context. This span will be a child of any spans propagated to the server in the request's metadata. The returned span is retrievable from the context via tracing.RootSpan.

func (*Tracer) StartSpanFromContext

func (t *Tracer) StartSpanFromContext(ctx context.Context, operationName string, opts ...ot.StartSpanOption) (ot.Span, context.Context)

StartSpanFromContext starts a new span and propagates it in ctx. If there exists a span in ctx it will be the parent of the returned span.

We provide this method, which should be used instead of opentracing.StartSpanFromContext because opentracing's version always uses the global tracer, while we use the opentracing.Tracer stored in t.

Jump to

Keyboard shortcuts

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