Documentation
¶
Overview ¶
Package telemetry defines the metrics interface for the e2a backend. Implementations:
- NoOp — production default until an operator wires a real backend.
- Log — structured log emitter; cheap; aggregator-friendly.
- (future) Prometheus, OTLP, statsd, etc.
The interface is small by design. Call sites should depend on telemetry.Metrics, not on a concrete backend. To swap backends, change the constructor at the cmd/e2a/main.go wiring; nothing else moves.
Index ¶
- type Log
- func (l *Log) JanitorRowsDeleted(table string, count int)
- func (l *Log) NotifyMissed()
- func (l *Log) OutboxEventsFanOut(eventType string, matched int)
- func (l *Log) OutboxEventsNoMatch(eventType string)
- func (l *Log) OutboxEventsPublished(eventType string)
- func (l *Log) OutboxFailures(stage string)
- func (l *Log) RedeliverRequests(scope string)
- func (l *Log) SetPublisherLag(seconds float64)
- type Metrics
- type NoOp
- func (NoOp) JanitorRowsDeleted(string, int)
- func (NoOp) NotifyMissed()
- func (NoOp) OutboxEventsFanOut(string, int)
- func (NoOp) OutboxEventsNoMatch(string)
- func (NoOp) OutboxEventsPublished(string)
- func (NoOp) OutboxFailures(string)
- func (NoOp) RedeliverRequests(string)
- func (NoOp) SetPublisherLag(float64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log emits a structured log line for every metric call. Cheap and portable; production aggregators (Loki, CloudWatch, Datadog) can build counters and gauges from these directly.
All lines share the [metrics] prefix so they're easy to filter. Format is key=value space-separated, which both jq and Splunk parse natively.
func (*Log) JanitorRowsDeleted ¶
func (*Log) NotifyMissed ¶
func (l *Log) NotifyMissed()
func (*Log) OutboxEventsFanOut ¶
func (*Log) OutboxEventsNoMatch ¶
func (*Log) OutboxEventsPublished ¶
func (*Log) OutboxFailures ¶
func (*Log) RedeliverRequests ¶
func (*Log) SetPublisherLag ¶
type Metrics ¶
type Metrics interface {
// OutboxEventsPublished is incremented each time PublishTx or
// PublishBestEffortTx successfully writes a webhook_events row.
OutboxEventsPublished(eventType string)
// OutboxEventsFanOut is incremented each time the worker finishes
// fanning an event out to its matched webhooks. matched is the
// number of webhook_subscriber_deliveries rows written.
OutboxEventsFanOut(eventType string, matched int)
// OutboxEventsNoMatch is incremented each time the worker
// transitions an event to status='no_match' because zero
// subscribers matched. Useful for spotting "why didn't my
// webhook fire?"
OutboxEventsNoMatch(eventType string)
// OutboxFailures is incremented on any worker-side failure.
// stage in {"lease", "list_webhooks", "insert_delivery", "update_status"}.
OutboxFailures(stage string)
// RedeliverRequests is incremented on each customer-driven replay.
// scope in {"single", "since"}.
RedeliverRequests(scope string)
// JanitorRowsDeleted is incremented by the cleanup tick.
// table in {"webhook_events", "webhook_subscriber_deliveries", "webhook_deliveries", "messages", "user_sessions", "oauth"}.
JanitorRowsDeleted(table string, count int)
// NotifyMissed is incremented when the 1-second fallback poll
// finds work that LISTEN/NOTIFY didn't wake us for. A non-zero
// rate indicates reconnect churn or a dropped notification.
NotifyMissed()
// SetPublisherLag is a gauge: the age in seconds of the oldest
// pending webhook_events row. Should be set on every Tick. Alert
// if it stays > 30s.
SetPublisherLag(seconds float64)
}
Metrics is the observability surface for the slice 10 design. Counter-style methods record a discrete event; SetPublisherLag is a gauge that should be set on each tick.
Stable across implementations. Adding a new metric is additive (add a method, default it to a no-op on existing implementations).
type NoOp ¶
type NoOp struct{}
NoOp swallows every call. Default for tests that don't care.
func (NoOp) JanitorRowsDeleted ¶
func (NoOp) NotifyMissed ¶
func (NoOp) NotifyMissed()