Documentation
¶
Overview ¶
Package batch sends items to an exporter in batches, from a goroutine, with a bounded queue and retries: what logging's sinks and tracing's exporters share.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsPermanent ¶
IsPermanent reports whether err was marked with Permanent.
Types ¶
type Config ¶
type Config struct {
// Name is the exporter's, for error lines: "otlp".
Name string
// Prefix starts each error line: "logging", "tracing".
Prefix string
// What the items are, plural: "entries", "spans".
What string
// ErrOut gets a line when exporting fails, at most once a minute;
// nil for none.
ErrOut io.Writer
// Close is called by Close after the last batch, if set.
Close func() error
}
Config names a shipper and says where its errors go.
type Options ¶
type Options struct {
Size int // default 512
Interval time.Duration // default 1s
Queue int // default 16384
MaxRetries int // default 5; -1 for none
// Timeout bounds each export. Default 15s.
Timeout time.Duration
}
Options says how items are sent. Items wait in a queue; a batch goes out when Size have gathered or Interval has passed. A batch that fails is retried MaxRetries times, pausing 1s, 2s, 4s… up to 30s between tries; meanwhile new items queue. When the queue holds Queue items, new ones are dropped and counted.
func (Options) WithDefaults ¶
WithDefaults fills in the zero fields.
type Shipper ¶
type Shipper[T any] struct { // Sleep pauses between tries; tests replace it. Sleep func(ctx context.Context, d time.Duration) bool // contains filtered or unexported fields }
Shipper queues items and exports them from a goroutine. Make one with New.
func (*Shipper[T]) Dropped ¶
Dropped counts items left out because the queue was full, or added after Close.