appdash: github.com/sourcegraph/appdash/opentracing Index | Files

package opentracing

import "github.com/sourcegraph/appdash/opentracing"

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

Package Files

json.go recorder.go tracer.go

func NewTracer Uses

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 Uses

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

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

type Options Uses

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 Uses

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 Uses

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

Recorder implements the basictracer.Recorder interface.

func NewRecorder Uses

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

NewRecorder forwards basictracer.RawSpans to an appdash.Collector.

func (*Recorder) RecordSpan Uses

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.

Package opentracing imports 9 packages (graph). Updated 2016-09-28. Refresh now. Tools for package owners.