tracing

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package tracing builds an OpenTelemetry TracerProvider that batches spans to the exporter in a resolved otelcore.Settings: a collector, a slog logger or a writer. It records no spans itself: install the provider globally and instrumentation such as go/transit's OTel middleware reads it from there.

Index

Constants

View Source
const DefaultSampling = 0.1

DefaultSampling is the parent-based ratio applied when none is configured. It is deliberately production-safe: set telemetry.tracing.sampling = 1.0 to record every trace while developing or following the tutorial.

Variables

This section is empty.

Functions

func NewProvider

func NewProvider(
	ctx context.Context,
	res *resource.Resource,
	s otelcore.Settings,
	opts ...Option,
) (*sdktrace.TracerProvider, error)

NewProvider builds a TracerProvider that batches spans to s.Exporter. A nil s.Exporter means otelcore.Collector{}, which reads the standard OTEL_EXPORTER_OTLP_* environment variables. Sampling is parent-based around a TraceID-ratio sampler, so a sampled trace stays whole across services.

The caller owns the returned provider's Shutdown — typically by registering it on the controls.Controller so spans flush on graceful stop.

Types

type Option

type Option func(*config)

Option configures the tracer provider.

func WithSampling

func WithSampling(ratio float64) Option

WithSampling sets the parent-based head sampling ratio (0.0–1.0). Defaults to DefaultSampling.

Jump to

Keyboard shortcuts

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