opentracing

package
v0.0.0-...-ffef430 Latest Latest
Warning

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

Go to latest
Published: May 10, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package opentracing provides an Appdash implementation of the OpenTracing API.

The OpenTracing specification allows for Span Tags to have an arbitrary value. The way the Appdash.Recorder handles this is by converting the tag value into a string using the default format for its type. Arbitrary structs have their field name included.

The Appdash implementation also does not record Log payloads.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTracer

func NewTracer(c appdash.Collector) opentracing.Tracer

NewTracer creates a new opentracing.Tracer implementation that reports spans to an Appdash collector.

The Tracer created by NewTracer reports all spans by default. If you want to sample 1 in every N spans, see NewTracerWithOptions. Spans are written to the underlying collector when Finish() is called on the span. It is possible to buffer and write span on a time interval using appdash.ChunkedCollector.

For example:

collector := appdash.NewLocalCollector(myAppdashStore)
chunkedCollector := appdash.NewChunkedCollector(collector)

tracer := NewTracer(chunkedCollector)

If writing traces to a remote Appdash collector, an appdash.RemoteCollector would be needed, for example:

collector := appdash.NewRemoteCollector("localhost:8700")
tracer := NewTracer(collector)

will record all spans to a collector server on localhost:8700.

func NewTracerWithOptions

func NewTracerWithOptions(c appdash.Collector, options Options) opentracing.Tracer

NewTracerWithOptions creates a new opentracing.Tracer that records spans to the given appdash.Collector.

Types

type Options

type Options struct {
	// ShouldSample is a function that allows deterministic sampling of a trace
	// using the randomly generated Trace ID. The decision is made when a new Trace
	// is created and is propagated to all of the trace's spans. For example,
	//
	//   func(traceID int64) { return traceID % 128 == 0 }
	//
	// samples 1 in every 128 traces, approximately.
	ShouldSample func(traceID uint64) bool

	// Verbose determines whether errors are logged to stdout only once or all
	// the time. By default, Verbose is false so only the first error is logged
	// and the rest are silenced.
	Verbose bool

	// Logger is used to log critical errors that can't be collected by the
	// Appdash Collector.
	Logger *log.Logger
}

Options defines options for a Tracer.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions creates an Option with a sampling function that always return true and a logger that logs errors to stderr.

type Recorder

type Recorder struct {
	Log *log.Logger
	// contains filtered or unexported fields
}

Recorder implements the basictracer.Recorder interface.

func NewRecorder

func NewRecorder(collector appdash.Collector, opts Options) *Recorder

NewRecorder forwards basictracer.RawSpans to an appdash.Collector.

func (*Recorder) RecordSpan

func (r *Recorder) RecordSpan(sp basictracer.RawSpan)

RecordSpan converts a RawSpan into the Appdash representation of a span and records it to the underlying collector.

Jump to

Keyboard shortcuts

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