package batchtraces

Import Path
	go.pact.im/x/traces/batchtraces (on go.dev)

Dependency Relation
	imports 7 packages, and imported by one package

Involved Source Files batcher.go Package batchtraces provides [traces.Handler] implementations backed by an [Exporter]. exporter.go options.go passthrough.go
Package-Level Type Names (total 7, in which 5 are exported)
/* sort exporteds by: | */
Batcher buffers finished spans in memory and periodically flushes them in batches to an [Exporter]. Batcher starts no goroutines in [NewBatcher]. Call [Batcher.Run] to run the flush loop; spans recorded while the batcher is not running are dropped and counted in [Stats.Dropped]. Handle implements the [traces.Handler] interface. It enqueues rec for batched export, or drops it if the batcher is not running. Run implements the [go.pact.im/x/process.Runner] interface. It starts the flush loop, invokes callback, and flushes remaining spans after callback returns. Stats returns a snapshot of the batcher’s counters. *Batcher : go.pact.im/x/traces.Handler *Batcher : go.pact.im/x/process.Runner func NewBatcher(exp Exporter, o Options) *Batcher
Exporter sends a batch of finished span records to a downstream destination. Implementations are synchronous and perform a single attempt; retries and backoff are composed by wrapping Exporter. Export sends batch to the destination. ExporterFunc *go.pact.im/x/traces/otlptraces.Exporter func NewBatcher(exp Exporter, o Options) *Batcher func Passthrough(exp Exporter) traces.Handler
ExporterFunc is a function that implements the [Exporter] interface. Export implements the [Exporter] interface. ExporterFunc : Exporter
Options is a set of options for [Batcher] constructor. Clock is the clock to use for periodic flush timers. Defaults to [clock.System]. FlushInterval is the time interval for periodic flushing. Defaults to 5s. MaxBatch is the maximum number of spans per export batch and the threshold that triggers an immediate flush. Defaults to 512. MaxExports is the maximum number of concurrent export calls in flight. When all export slots are busy, new flushes drop the batch and count the spans in [Stats.Dropped]. Defaults to 4. OnError specifies a callback invoked when [Exporter.Export] returns a non-nil error. If not set, export errors are ignored and still counted in [Stats.Failed]. func NewBatcher(exp Exporter, o Options) *Batcher
Stats is a point-in-time snapshot of [Batcher] counters. Dropped is the number of spans dropped because all export slots were busy or because the batcher was not running. Exported is the number of spans successfully exported. Failed is the number of spans whose Export call returned an error. func (*Batcher).Stats() Stats
Package-Level Functions (total 2, both are exported)
NewBatcher returns a new [Batcher] instance.
Passthrough returns a [traces.Handler] implementation that immediately exports each finished span synchronously instead of batching.
Package-Level Variables (only one, which is unexported)
Package-Level Constants (total 3, none are exported)