tracer

package
v3.9.14 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: Apache-2.0 Imports: 2 Imported by: 12

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 DefaultTracer = NewTracer()

DefaultTracer is the global default tracer

Functions

func NewContext

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

NewContext saves the tracer in the context

func NewSpanContext

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

NewSpanContext saves the span in the context

Types

type EventOption

type EventOption func(o *EventOptions)

EventOption func signature

type EventOptions

type EventOptions struct{}

EventOptions contains event options

type Label

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

func LabelAny added in v3.8.1

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

func LabelBool added in v3.8.1

func LabelBool(k string, v bool) Label

func LabelFloat64 added in v3.8.1

func LabelFloat64(k string, v float64) Label

func LabelInt added in v3.8.1

func LabelInt(k string, v int) Label

func LabelInt64 added in v3.8.1

func LabelInt64(k string, v int64) Label

func LabelString added in v3.8.1

func LabelString(k string, v string) Label

type Option

type Option func(o *Options)

Option func signature

func Logger

func Logger(l logger.Logger) Option

Logger sets the logger

func Name

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

func SpanFromContext(ctx context.Context) (Span, bool)

SpanFromContext returns a span from context

type SpanOption

type SpanOption func(o *SpanOptions)

SpanOption func signature

type SpanOptions

type SpanOptions struct{}

SpanOptions contains span option

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

func FromContext

func FromContext(ctx context.Context) (Tracer, bool)

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