gtrace

package
v1.16.2 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package gtrace provides convenience wrapping functionality for tracing feature using OpenTelemetry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommonLabels

func CommonLabels() []label.KeyValue

CommonLabels returns common used attribute labels: ip.intranet, hostname.

func GetBaggageMap

func GetBaggageMap(ctx context.Context) *gmap.StrAnyMap

GetBaggageMap retrieves and returns the baggage values as map.

func GetBaggageVar

func GetBaggageVar(ctx context.Context, key string) *gvar.Var

GetBaggageVar retrieves value and returns a *gvar.Var for specified key from baggage.

func GetSpanId

func GetSpanId(ctx context.Context) string

GetSpanId retrieves and returns SpanId from context. It returns an empty string is tracing feature is not activated.

func GetTraceId

func GetTraceId(ctx context.Context) string

GetTraceId retrieves and returns TraceId from context. It returns an empty string is tracing feature is not activated.

func IsActivated

func IsActivated(ctx context.Context) bool

IsActivated checks and returns if tracing feature is activated.

func SetBaggageMap

func SetBaggageMap(ctx context.Context, data map[string]interface{}) context.Context

SetBaggageMap is a convenient function for adding map key-value pairs to baggage. Note that it uses label.Any to set the key-value pair.

func SetBaggageValue

func SetBaggageValue(ctx context.Context, key string, value interface{}) context.Context

SetBaggageValue is a convenient function for adding one key-value pair to baggage. Note that it uses label.Any to set the key-value pair.

Types

type Baggage

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

Baggage holds the data through all tracing spans.

func NewBaggage

func NewBaggage(ctx context.Context) *Baggage

NewBaggage creates and returns a new Baggage object from given tracing context.

func (*Baggage) Ctx

func (b *Baggage) Ctx() context.Context

Ctx returns the context that Baggage holds.

func (*Baggage) GetMap

func (b *Baggage) GetMap() *gmap.StrAnyMap

GetMap retrieves and returns the baggage values as map.

func (*Baggage) GetVar

func (b *Baggage) GetVar(key string) *gvar.Var

GetVar retrieves value and returns a *gvar.Var for specified key from baggage.

func (*Baggage) SetMap

func (b *Baggage) SetMap(data map[string]interface{}) context.Context

SetMap is a convenient function for adding map key-value pairs to baggage. Note that it uses label.Any to set the key-value pair.

func (*Baggage) SetValue

func (b *Baggage) SetValue(key string, value interface{}) context.Context

SetValue is a convenient function for adding one key-value pair to baggage. Note that it uses label.Any to set the key-value pair.

type Span

type Span struct {
	trace.Span
}

func NewSpan

func NewSpan(ctx context.Context, spanName string, opts ...trace.SpanOption) (context.Context, *Span)

NewSpan creates a span using default tracer.

type Tracer

type Tracer struct {
	trace.Tracer
}

func NewTracer

func NewTracer(name ...string) *Tracer

Tracer is a short function for retrieving Tracer.

Jump to

Keyboard shortcuts

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