Package opentracing
Overview ▹
Index ▹
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.
type Options ¶
Options defines options for a Tracer.
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
}
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 ¶
Recorder implements the basictracer.Recorder interface.
type Recorder struct {
Log *log.Logger
// contains filtered or unexported fields
}
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.
ActiveGo 1.8