trace

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitTracing

func InitTracing(ctx context.Context, cfg *Config, lg *zap.Logger) (func(context.Context) error, error)

InitTracing initializes OpenTelemetry tracing and returns a shutdown func

Types

type Builder

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

Builder is a small wrapper to access a named tracer with fluent helpers

func Tracer

func Tracer(name string) *Builder

Tracer creates a Builder for a named tracer

func (*Builder) Start

func (b *Builder) Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption) *SpanScope

Start starts a new span and returns a scope

type CaptureConfig

type CaptureConfig struct {
	DownstreamError struct {
		Enabled       bool `yaml:"enabled"`
		MaxBodyLength int  `yaml:"max_body_length"`
	} `yaml:"downstream_error"`
	DownstreamRequest struct {
		Enabled        bool      `yaml:"enabled"`
		IncludeFields  StringMap `yaml:"include_fields"`
		MaxFieldLength int       `yaml:"max_field_length"`
		BodyEnabled    bool      `yaml:"body_enabled"`
		BodyMaxLength  int       `yaml:"body_max_length"`
	} `yaml:"downstream_request"`
	DownstreamResponse struct {
		Enabled       bool `yaml:"enabled"`
		MaxBodyLength int  `yaml:"max_body_length"`
	} `yaml:"downstream_response"`
}

CaptureConfig controls extra trace capture behavior

type Config

type Config struct {
	Enabled     bool              `yaml:"enabled"`
	ServiceName string            `yaml:"service_name"`
	Endpoint    string            `yaml:"endpoint"`     // e.g. localhost:4317 or http://localhost:4318
	Protocol    string            `yaml:"protocol"`     // grpc or http
	Insecure    bool              `yaml:"insecure"`     // allow insecure connection
	SamplerRate float64           `yaml:"sampler_rate"` // 0.0~1.0
	Environment string            `yaml:"environment"`  // env tag: dev/staging/prod
	Headers     map[string]string `yaml:"headers"`
	Capture     CaptureConfig     `yaml:"capture"`
}

Config represents OpenTelemetry/Jaeger tracing configuration

type SpanScope

type SpanScope struct {
	Ctx  context.Context
	Span trace.Span
}

SpanScope holds span and context, with fluent helpers

func (*SpanScope) End

func (s *SpanScope) End()

End ends the span if present

func (*SpanScope) WithAttrs

func (s *SpanScope) WithAttrs(attrs ...attribute.KeyValue) *SpanScope

WithAttrs sets attributes on the span and returns the scope for chaining

type StringMap added in v0.9.1

type StringMap map[string]string

StringMap is a generic map[string]string type that supports: 1. YAML maps 2. JSON strings 3. CSV strings like "k1=v1,k2=v2"

func (*StringMap) UnmarshalYAML added in v0.9.1

func (m *StringMap) UnmarshalYAML(value *yaml.Node) error

Jump to

Keyboard shortcuts

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