Version: v1.2.17 Latest Latest

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

Go to latest
Published: Nov 30, 2021 License: MIT Imports: 12 Imported by: 0




View Source
const (
	// HttpFormat means http carrier format.
	HttpFormat = iota
	// GrpcFormat means grpc carrier format.


View Source
var ErrInvalidCarrier = errors.New("invalid carrier")

ErrInvalidCarrier indicates an error that the carrier is invalid.


func Now

func Now() time.Duration

Now returns a relative time duration since initTime, which is not important. The caller only needs to care about the relative value.

func RandId

func RandId() string

RandId returns a random id string.

func Randn

func Randn(n int) string

Randn returns a random string with length n.

func Since

func Since(d time.Duration) time.Duration

Since returns a diff since given d.

func StartClientSpan

func StartClientSpan(ctx context.Context, serviceName, operationName string) (context.Context, tracespec.Trace)

StartClientSpan starts the client span with given context, service and operation names.

func StartServerSpan

func StartServerSpan(ctx context.Context, carrier Carrier, serviceName, operationName string) (
	context.Context, tracespec.Trace)

StartServerSpan starts the server span with given context, carrier, service and operation names.

func TakeWithPriority

func TakeWithPriority(fns ...func() string) string

TakeWithPriority returns the first not empty result from fns.

func Time

func Time() time.Time

Time returns current time, the same as time.Now().


type Carrier

type Carrier interface {
	Get(key string) string
	Set(key, value string)

Carrier interface wraps the Get and Set method.

func Extract

func Extract(format, carrier interface{}) (Carrier, error)

Extract extracts tracing information from carrier with given format.

func Inject

func Inject(format, carrier interface{}) (Carrier, error)

Inject injects tracing information into carrier with given format.

type Propagator

type Propagator interface {
	Extract(carrier interface{}) (Carrier, error)
	Inject(carrier interface{}) (Carrier, error)

Propagator interface wraps the Extract and Inject methods.

type Span

type Span struct {
	// contains filtered or unexported fields

A Span is a calling span that connects caller and callee.

func (*Span) Finish

func (s *Span) Finish()

Finish finishes the calling span.

func (*Span) Follow

func (s *Span) Follow(ctx context.Context, serviceName, operationName string) (context.Context, tracespec.Trace)

Follow follows the tracing service and operation names in context.

func (*Span) Fork

func (s *Span) Fork(ctx context.Context, serviceName, operationName string) (context.Context, tracespec.Trace)

Fork forks the tracing service and operation names in context.

func (*Span) SpanId

func (s *Span) SpanId() string

SpanId returns the span id.

func (*Span) TraceId

func (s *Span) TraceId() string

TraceId returns the trace id.

func (*Span) Visit

func (s *Span) Visit(fn func(key, val string) bool)

Visit visits the span using fn.


Path Synopsis

Jump to

Keyboard shortcuts

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