tracing

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotCompiled = errors.New("tracing enabled but binary was built without sdkit_tracing_otel")

Functions

func Enabled

func Enabled() bool

func Init

func Init(ctx context.Context, cfg Config) (func(context.Context) error, error)

func RegisterProvider

func RegisterProvider(name string, provider Provider)

func Shutdown

func Shutdown(ctx context.Context) error

Types

type Attr

type Attr struct {
	Key   string
	Value any
}

func Bool

func Bool(key string, value bool) Attr

func Float64

func Float64(key string, value float64) Attr

func Int

func Int(key string, value int) Attr

func Int64

func Int64(key string, value int64) Attr

func String

func String(key string, value string) Attr

type Config

type Config struct {
	Enabled     bool          `mapstructure:"enabled" yaml:"enabled"`
	ServiceName string        `mapstructure:"service_name" yaml:"service_name"`
	Environment string        `mapstructure:"environment" yaml:"environment"`
	Endpoint    string        `mapstructure:"endpoint" yaml:"endpoint"`
	Insecure    bool          `mapstructure:"insecure" yaml:"insecure"`
	SampleRatio float64       `mapstructure:"sample_ratio" yaml:"sample_ratio"`
	Strict      bool          `mapstructure:"strict" yaml:"strict"`
	Timeout     time.Duration `mapstructure:"timeout" yaml:"timeout"`
}

func DefaultConfig

func DefaultConfig() Config

func NormalizeConfig

func NormalizeConfig(cfg Config) Config

type Provider

type Provider interface {
	Init(context.Context, Config) (func(context.Context) error, error)
	StartSpan(context.Context, string, SpanOptions, ...Attr) (context.Context, Span)
	InjectCarrier(context.Context, tracecontext.Carrier)
	ExtractCarrier(context.Context, tracecontext.Carrier) context.Context
}

type Span

type Span interface {
	End()
	IsRecording() bool
	RecordError(error)
	SetStatus(StatusCode, string)
	SetAttributes(...Attr)
	TraceID() string
	SpanID() string
}

func StartSpan

func StartSpan(ctx context.Context, name string, attrs ...Attr) (context.Context, Span)

func StartSpanWithOptions

func StartSpanWithOptions(ctx context.Context, name string, opts SpanOptions, attrs ...Attr) (context.Context, Span)

type SpanKind

type SpanKind string
const (
	SpanKindInternal SpanKind = "internal"
	SpanKindServer   SpanKind = "server"
	SpanKindProducer SpanKind = "producer"
	SpanKindConsumer SpanKind = "consumer"
)

type SpanOptions

type SpanOptions struct {
	TracerName string
	Kind       SpanKind
}

type StatusCode

type StatusCode string
const (
	StatusUnset StatusCode = ""
	StatusOK    StatusCode = "ok"
	StatusError StatusCode = "error"
)

Jump to

Keyboard shortcuts

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