tracer

package
v3.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: Apache-2.0 Imports: 2 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

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, tracer Tracer) context.Context

NewContext saves the tracer in the context

func NewSpanContext added in v3.2.16

func NewSpanContext(ctx context.Context, span Span) context.Context

NewSpanContext saves the span in the context

Types

type EventOption added in v3.2.16

type EventOption func(o *EventOptions)

type EventOptions added in v3.2.16

type EventOptions struct{}

type Label added in v3.2.16

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

func Any added in v3.2.16

func Any(k string, v interface{}) Label

func Bool added in v3.2.16

func Bool(k string, v bool) Label

func Float64 added in v3.2.16

func Float64(k string, v float64) Label

func Int added in v3.2.16

func Int(k string, v int) Label

func Int64 added in v3.2.16

func Int64(k string, v int64) Label

func String added in v3.2.16

func String(k string, v string) Label

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 {
	// Logger used for logging
	Logger logger.Logger
	// Name of the tracer
	Name string
}

Options struct

func NewOptions

func NewOptions(opts ...Option) Options

NewOptions returns default options

type Span

type Span interface {
	// Tracer return underlining tracer
	Tracer() Tracer
	// Finish complete and send span
	Finish(opts ...SpanOption)
	// AddEvent add event to span
	AddEvent(name string, opts ...EventOption)
	// Context return context with span
	Context() context.Context
	// SetName set the span name
	SetName(name string)
	// SetLabels set the span labels
	SetLabels(labels ...Label)
}

func SpanFromContext added in v3.2.16

func SpanFromContext(ctx context.Context) Span

SpanFromContext returns a span from context

type SpanOption added in v3.2.16

type SpanOption func(o *SpanOptions)

type SpanOptions added in v3.2.16

type SpanOptions struct{}

type Tracer

type Tracer interface {
	// Name return tracer name
	Name() string
	// Init tracer with options
	Init(...Option) error
	// Start a trace
	Start(ctx context.Context, name string, opts ...SpanOption) (context.Context, Span)
}

Tracer is an interface for distributed tracing

var DefaultTracer Tracer = NewTracer()

DefaultTracer is the global default tracer

func FromContext

func FromContext(ctx context.Context) Tracer

FromContext returns a tracer from context

func NewTracer

func NewTracer(opts ...Option) Tracer

NewTracer returns new memory tracer

Directories

Path Synopsis
Package wrapper provides wrapper for Tracer
Package wrapper provides wrapper for Tracer

Jump to

Keyboard shortcuts

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