rolluptracer

package module
v0.0.0-...-10b777e Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2020 License: MIT Imports: 6 Imported by: 0

README

Rollup Tracer

RollupTracer is a simple OpenTracing tracer that wraps another tracer and "rolls" up intermediate spans to a common ancestor. It's intended to be used in heavily-instrumented codebases, where many of the intermediate spans are useful for debugging during development, but let useful in a production environment.

The tracer rolls up the tags and durations of all the spans it creates to the nearest "real" span, applying a hierarchical namespace scheme based on the operation names of the spans.

The implementation is currently pretty naive - in particular, it does not deal with the creation of multiple child spans at the same level with the same operation name.

The tracer offers an additional way to create spans: StartRealSpan. This delegates directly to the parent tracer to create a "real" span, as a direct child of the nearest "real" ancestor of the parent context provided (if any).

The tracer automatically creates a "real" span for any span tagged with the following span.kind at span-creation time:

  • client
  • server
  • producer
  • consumer

This code is, at best, a proof of concept. It works as far as I know, but testing has been minimal.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRollupTracer

func NewRollupTracer(parent opentracing.Tracer) opentracing.Tracer

NewRollupTracer creates a RollupTracer wrapping the parent tracer provided

Types

type RollupTracer

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

RollupTracer wraps another tracer, and produces spans which roll up tags and durations to the nearest ancestor span from the parent tracer.

func (*RollupTracer) Extract

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

Extract returns a SpanContext instance given `format` and `carrier`.

func (*RollupTracer) Inject

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

Inject takes the `sm` SpanContext instance and injects it for propagation within `carrier`. The actual type of `carrier` depends on the value of `format`.

func (*RollupTracer) StartRealSpan

func (t *RollupTracer) StartRealSpan(operationName string, opts ...opentracing.StartSpanOption) opentracing.Span

StartRealSpan delegates to the parent tracer to start a "real" span. This creates a new rollup context.

func (*RollupTracer) StartSpan

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

StartSpan creates, starts, and returns a new Span with the given `operationName` and incorporate the given StartSpanOption `opts`.

Jump to

Keyboard shortcuts

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