Documentation
¶
Overview ¶
Package sink is the write side every collector module uses. The agent's OTLP exporter satisfies it; tests use a recorder.
Index ¶
- Constants
- func Backoff(attempt int, r float64) time.Duration
- func Res(attrs map[string]string) map[string]string
- func SplitRes(attrs map[string]string) (res, rest map[string]string)
- func Strip(attrs map[string]string) map[string]string
- func Truncate(s string, n int) string
- func With(attrs map[string]string, kv ...string) map[string]string
- type Delivering
- type Recorder
- func (r *Recorder) Gauge(name, _ string, v float64, a map[string]string, _ time.Time)
- func (r *Recorder) Log(sev, body string, a map[string]string, _ time.Time)
- func (r *Recorder) Names() map[string]bool
- func (r *Recorder) Snapshot() []Sample
- func (r *Recorder) Sum(name, unit string, v float64, a map[string]string, at time.Time)
- type ResourceSink
- type Sample
- type Sink
Constants ¶
const ( QueueDepth = "messaging.queue.depth" QueueAge = "messaging.queue.oldest_age_seconds" QueueLag = "messaging.consumer.lag_seconds" )
The Queues area (APM-009) reads one metric contract whatever the broker: messaging.queue.depth {queue, framework, state}, messaging.queue.oldest_age_seconds and messaging.consumer.lag_seconds. QueueContract wraps a Sink and, for each broker metric in queueMaps, also writes that contract series, so every collector (RabbitMQ, ActiveMQ and Artemis, NATS JetStream, Pulsar, Kafka, Redis streams, SQS, Kinesis, Service Bus, Pub/Sub) feeds the data-streams view without changing its own native series. A point without a queue name is skipped.
const ResourcePrefix = "resource."
ResourcePrefix marks, inside the modules that Hoist, an attribute that belongs on the OTLP resource. The exporter itself never reads it: Hoist (applied only by trusted modules: Kubernetes, virtualization, cloud and docker, whose values come from an API and not from scraped input) turns the prefixed keys into explicit resource arguments, so a scraped label or any other module's attribute can never name the resource. Keys must not be `wt.*` (ingest deletes them).
Variables ¶
This section is empty.
Functions ¶
func Backoff ¶
Backoff is the wait before retry number attempt (0 is the first): 1 s doubling to 5 min, with a random 20% either way. r is a uniform value in [0,1) (pass rand.Float64()).
func SplitRes ¶
SplitRes separates ResourcePrefix keys (prefix removed) from the rest. With none it returns (nil, attrs) unchanged.
func Strip ¶
Strip returns attrs without ResourcePrefix keys (a copy only when one is present). Modules that copy outside input into attributes use it.
Types ¶
type Delivering ¶
type Delivering interface {
// Flush exports everything buffered now (and waits for an export already in flight).
Flush(ctx context.Context) error
// Buffered is the estimated number of bytes waiting to be exported.
Buffered() int
}
Delivering is implemented by a sink that can confirm delivery. A collector that reads from a source with offsets (Kafka, Event Hubs) commits them only after Flush returns nil, and pauses its reads while Buffered is above its high-water mark, so a slow or failing export never makes the sink drop what the source already considers delivered.
type Recorder ¶
type Recorder struct {
Samples []Sample
// contains filtered or unexported fields
}
Recorder is a Sink that keeps everything it is given (for tests).
type ResourceSink ¶
type ResourceSink interface {
GaugeRes(name, unit string, value float64, res, attrs map[string]string, at time.Time)
SumRes(name, unit string, value float64, res, attrs map[string]string, at time.Time)
LogRes(severity, body string, res, attrs map[string]string, at time.Time)
}
ResourceSink is a Sink that also accepts resource attributes as a separate argument.
type Sink ¶
type Sink interface {
Gauge(name, unit string, value float64, attrs map[string]string, at time.Time)
// Sum is a cumulative monotonic counter.
Sum(name, unit string, value float64, attrs map[string]string, at time.Time)
Log(severity, body string, attrs map[string]string, at time.Time)
}
Sink receives samples and log records.
func Hoist ¶
Hoist wraps out so ResourcePrefix keys become resource attributes. It is used only by the Kubernetes modules; out is returned unchanged when it cannot take resource attributes (then the prefixed keys stay ordinary attributes).
func QueueContract ¶ added in v0.3.1
QueueContract returns out with the Queues-area series added next to the broker's own.