tracing

package
v0.6.13 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OTLPGRPC = "otlpgrpc"
	OTLPHTTP = "otlphttp"
	Stdout   = "stdout"
)

Exporter names, the values of the tracing.exporter config key and WithExporter. Each maps to a subpackage under pkg/services/tracing/exporters that registers its Factory during init().

Variables

This section is empty.

Functions

func Register

func Register(name string, f Factory)

Register makes a Factory available under the given exporter name. It is meant to be called from the init() of an exporter subpackage; double-registration panics so misconfiguration surfaces at startup.

Types

type Factory

type Factory func(ctx context.Context, config []byte) (sdktrace.SpanExporter, error)

Factory builds a SpanExporter from the tracing.config block, handed over as raw YAML - nil when the block is absent. Different exporters need different config shapes, so the manager never interprets the block: each factory strict-decodes its own config struct and fails the build on unknown keys, the same contract api.Middleware.Func has with its config bytes. Each exporter subpackage under pkg/services/tracing/exporters/* registers one during its init() so the core package never links exporter machinery (grpc most of all) into binaries that don't use it. An exporter whose construction config cannot express (vendor SDKs, dial options, credential objects) is still a Factory: the app Registers its own under a name - a closure captures whatever it needs and may ignore config.

type Manager

type Manager interface {
	// business
	model.Tracer
	// health.go: Alive guards the manager's own wiring only (enabled but no
	// provider built - Init rebuilds it, so a restart is the remedy). There
	// is deliberately NO common.Readiness: tracing is auxiliary, so an
	// unreachable collector must never gate app readiness - and the monitor
	// rolls a dependency's probes into every dependent's healthcheck, which
	// would let a dead collector degrade the api server.
	common.Liveness
	// lifecycle
	common.Initializable
	common.Daemon
	common.Debuggable
}

func New

func New(opts ...Option) Manager

type Option

type Option func(*manager)

func WithEnabled

func WithEnabled(enabled bool) Option

WithEnabled switches the service on or off, carrying the wiring layer's reading of tracing.enabled - which the same key overrides on every Init, since it is also read there. Enabling is its own decision: WithExporter says where spans would go, never that tracing is on.

func WithExporter

func WithExporter(name string, config map[string]any) Option

WithExporter picks a registry exporter by name together with the config block its factory strict-decodes - one decision, since the block only has meaning for the exporter that reads it. nil config means the exporter's defaults. The programmatic twin of the tracing.exporter + tracing.config yaml keys, which override it when set. An exporter whose construction no config can express is registered as an app-owned Factory (tracing.Register) - a closure captures whatever it needs - and picked here by its name.

Choosing where spans would go does not turn tracing on: enabling is ops state, not a wiring decision, so tracing.enabled is the only thing that does it and there is no option for it.

func WithLogger

func WithLogger(logger log.Logger) Option

func WithName

func WithName(name string) Option

func WithSampleRatio

func WithSampleRatio(ratio float64) Option

WithSampleRatio sets the head sampling ratio, which Init wraps in ParentBased so a remote parent's decision still wins. Zero reads as unset - newManager defaults it - since Go cannot tell an absent ratio from an explicit one, which lets a wiring layer pass a missing config key straight through. Viper does distinguish unset, so a config file can still ask for zero.

Directories

Path Synopsis
exporters
model
Package model is the tracing factories' config vocabulary: the shared exporter core from pkg/utils/otelutil plus the span-exporter-only max_request_size knob.
Package model is the tracing factories' config vocabulary: the shared exporter core from pkg/utils/otelutil plus the span-exporter-only max_request_size knob.
otlpgrpc
Package otlpgrpc registers the OTLP-over-gRPC span exporter under tracing.OTLPGRPC.
Package otlpgrpc registers the OTLP-over-gRPC span exporter under tracing.OTLPGRPC.
otlphttp
Package otlphttp registers the OTLP-over-HTTP span exporter under tracing.OTLPHTTP.
Package otlphttp registers the OTLP-over-HTTP span exporter under tracing.OTLPHTTP.
stdout
Package stdout registers the stdout span exporter under tracing.Stdout.
Package stdout registers the stdout span exporter under tracing.Stdout.

Jump to

Keyboard shortcuts

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