tracing

package
v2.0.0-alpha8+incompat... Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const OperationNameMaxLengthNumber = 10

OperationNameMaxLengthNumber defines the number of static characters in a Span Trace name: 8 chars for hash + 2 chars for '_'.

View Source
const (
	// SpanKindNoneEnum Span kind enum none.
	SpanKindNoneEnum ext.SpanKindEnum = "none"
)
View Source
const TraceNameHashLength = 8

TraceNameHashLength defines the number of characters to use from the head of the generated hash.

Variables

This section is empty.

Functions

func GetSpan

func GetSpan(r *http.Request) opentracing.Span

GetSpan used to retrieve span from request context.

func InjectRequestHeaders

func InjectRequestHeaders(r *http.Request)

InjectRequestHeaders used to inject OpenTracing headers into the request.

func LogEventf

func LogEventf(r *http.Request, format string, args ...interface{})

LogEventf logs an event to the span in the request context.

func LogRequest

func LogRequest(span opentracing.Span, r *http.Request)

LogRequest used to create span tags from the request.

func LogResponseCode

func LogResponseCode(span opentracing.Span, code int)

LogResponseCode used to log response code in span.

func SetError

func SetError(r *http.Request)

SetError flags the span associated with this request as in error.

func SetErrorWithEvent

func SetErrorWithEvent(r *http.Request, format string, args ...interface{})

SetErrorWithEvent flags the span associated with this request as in error and log an event.

func StartSpan

func StartSpan(r *http.Request, operationName string, spanKind ext.SpanKindEnum, opts ...opentracing.StartSpanOption) (opentracing.Span, *http.Request, func())

StartSpan starts a new span from the one in the request context

func WithTracing

func WithTracing(ctx context.Context, tracing *Tracing) context.Context

WithTracing Adds Tracing into the context.

Types

type Backend

type Backend interface {
	Setup(componentName string) (opentracing.Tracer, io.Closer, error)
}

Backend is an abstraction for tracking backend (Jaeger, Zipkin, ...).

type HTTPHeadersCarrier

type HTTPHeadersCarrier http.Header

HTTPHeadersCarrier custom implementation to fix duplicated headers It has been fixed in https://github.com/opentracing/opentracing-go/pull/191

func (HTTPHeadersCarrier) ForeachKey

func (c HTTPHeadersCarrier) ForeachKey(handler func(key, val string) error) error

ForeachKey conforms to the TextMapReader interface.

func (HTTPHeadersCarrier) Set

func (c HTTPHeadersCarrier) Set(key, val string)

Set conforms to the TextMapWriter interface.

type Tracing

type Tracing struct {
	ServiceName   string `description:"Set the name for this service" export:"true"`
	SpanNameLimit int    `description:"Set the maximum character limit for Span names (default 0 = no limit)" export:"true"`
	// contains filtered or unexported fields
}

Tracing middleware.

func FromContext

func FromContext(ctx context.Context) (*Tracing, error)

FromContext Gets Tracing from context.

func NewTracing

func NewTracing(serviceName string, spanNameLimit int, tracingBackend Backend) (*Tracing, error)

NewTracing Creates a Tracing.

func (*Tracing) Close

func (t *Tracing) Close()

Close tracer

func (*Tracing) Extract

func (t *Tracing) Extract(format interface{}, carrier interface{}) (opentracing.SpanContext, error)

Extract delegates to opentracing.Tracer.

func (*Tracing) Inject

func (t *Tracing) Inject(sm opentracing.SpanContext, format interface{}, carrier interface{}) error

Inject delegates to opentracing.Tracer.

func (*Tracing) IsEnabled

func (t *Tracing) IsEnabled() bool

IsEnabled determines if tracing was successfully activated.

func (*Tracing) StartSpan

func (t *Tracing) StartSpan(operationName string, opts ...opentracing.StartSpanOption) opentracing.Span

StartSpan delegates to opentracing.Tracer.

func (*Tracing) StartSpanf

func (t *Tracing) StartSpanf(r *http.Request, spanKind ext.SpanKindEnum, opPrefix string, opParts []string, separator string, opts ...opentracing.StartSpanOption) (opentracing.Span, *http.Request, func())

StartSpanf delegates to StartSpan.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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