tracer

package
v3.2.14 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package tracer provides an interface for distributed tracing

Package tracer provides an interface for distributed tracing

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultSize of the buffer
	DefaultSize = 64
)

Functions

func FromContext

func FromContext(ctx context.Context) (traceID string, parentSpanID string, isFound bool)

FromContext returns a span from context

func NewContext

func NewContext(ctx context.Context, traceID, parentSpanID string) context.Context

NewContext saves the trace and span ids in the context

Types

type Option

type Option func(o *Options)

Option func

func Logger added in v3.1.0

func Logger(l logger.Logger) Option

Logger sets the logger

func Name added in v3.2.1

func Name(n string) Option

Name sets the name

type Options

type Options struct {
	Name string
	// Logger is the logger for messages
	Logger logger.Logger
	// Size is the size of ring buffer
	Size int
}

Options struct

func NewOptions

func NewOptions(opts ...Option) Options

NewOptions returns default options

type ReadOption

type ReadOption func(o *ReadOptions)

ReadOption func

func ReadTrace

func ReadTrace(t string) ReadOption

ReadTrace read the given trace

type ReadOptions

type ReadOptions struct {
	// Trace id
	Trace string
}

ReadOptions struct

type Span

type Span struct {
	// Id of the trace
	Trace string
	// name of the span
	Name string
	// id of the span
	Id string
	// parent span id
	Parent string
	// Start time
	Started time.Time
	// Duration in nano seconds
	Duration time.Duration
	// associated data
	Metadata metadata.Metadata
	// Type
	Type SpanType
}

Span is used to record an entry

type SpanType

type SpanType int

SpanType describe the nature of the trace span

const (
	// SpanTypeRequestInbound is a span created when serving a request
	SpanTypeRequestInbound SpanType = iota
	// SpanTypeRequestOutbound is a span created when making a service call
	SpanTypeRequestOutbound
)

type Tracer

type Tracer interface {
	Name() string
	Init(...Option) error
	// Start a trace
	Start(ctx context.Context, name string) (context.Context, *Span)
	// Finish the trace
	Finish(*Span) error
	// Lookup get span from context
	Lookup(ctx context.Context) (*Span, error)
	// Read the traces
	Read(...ReadOption) ([]*Span, error)
}

Tracer is an interface for distributed tracing

var (
	// DefaultTracer is the global default tracer
	DefaultTracer Tracer = NewTracer()
)

func NewTracer

func NewTracer(opts ...Option) Tracer

NewTracer returns new memory tracer

Jump to

Keyboard shortcuts

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