forwarder

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Forwarder

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

Forwarder fans out OTLP payloads to one or more upstream HTTP endpoints.

func New

func New(urls []string, sample float64) *Forwarder

New returns a Forwarder in fire-and-forget mode (no spool, no retry). urls should be bare base URLs, e.g. "http://tempo:4318". sample is the per-payload forwarding probability in [0, 1]; values outside the range are clamped (NaN → 1.0).

func NewWithSpool added in v0.2.0

func NewWithSpool(urls []string, sample float64, sc SpoolConfig) *Forwarder

NewWithSpool returns a Forwarder backed by a per-upstream disk spool. Failed deliveries are retried with exponential backoff (250ms → sc.RetryMax). Each upstream gets a send-loop goroutine that runs for the process lifetime.

func (*Forwarder) Forward

func (f *Forwarder) Forward(path, contentType string, body []byte)

Forward asynchronously delivers body to each upstream at <base>/path. When a spool is configured the payload is written to disk first and the send loop handles delivery; otherwise a goroutine fires immediately. Per-upstream sampling is applied before any I/O.

func (*Forwarder) Status

func (f *Forwarder) Status() []Status

Status returns a snapshot of each upstream's counters.

type SpoolConfig added in v0.2.0

type SpoolConfig struct {
	Dir      string        // spool directory; default: ~/.spaniel/forward
	MaxBytes int64         // max pending bytes per upstream; default: 100 MB
	RetryMax time.Duration // max backoff between retries; default: 30s
}

SpoolConfig controls the disk-backed retry buffer. Zero values cause NewWithSpool to use its built-in defaults.

type Status

type Status struct {
	URL           string `json:"url"`
	Sent          int64  `json:"sent"`
	Errors        int64  `json:"errors"`
	Skipped       int64  `json:"skipped"`
	LastErr       string `json:"last_error,omitempty"`
	PendingBytes  int64  `json:"pending_bytes,omitempty"`
	DroppedSpool  int64  `json:"dropped_spool,omitempty"`
	LastFailureAt int64  `json:"last_failure_at,omitempty"`
	BackoffNs     int64  `json:"backoff_ns,omitempty"`
}

Status is the serialisable snapshot of one upstream's counters.

Jump to

Keyboard shortcuts

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