telemetry

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

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

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 NewLog

func NewLog() *Log

func (*Log) JanitorRowsDeleted

func (l *Log) JanitorRowsDeleted(table string, count int)

func (*Log) NotifyMissed

func (l *Log) NotifyMissed()

func (*Log) OutboxEventsFanOut

func (l *Log) OutboxEventsFanOut(eventType string, matched int)

func (*Log) OutboxEventsNoMatch

func (l *Log) OutboxEventsNoMatch(eventType string)

func (*Log) OutboxEventsPublished

func (l *Log) OutboxEventsPublished(eventType string)

func (*Log) OutboxFailures

func (l *Log) OutboxFailures(stage string)

func (*Log) RedeliverRequests

func (l *Log) RedeliverRequests(scope string)

func (*Log) SetPublisherLag

func (l *Log) SetPublisherLag(seconds float64)

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) JanitorRowsDeleted(string, int)

func (NoOp) NotifyMissed

func (NoOp) NotifyMissed()

func (NoOp) OutboxEventsFanOut

func (NoOp) OutboxEventsFanOut(string, int)

func (NoOp) OutboxEventsNoMatch

func (NoOp) OutboxEventsNoMatch(string)

func (NoOp) OutboxEventsPublished

func (NoOp) OutboxEventsPublished(string)

func (NoOp) OutboxFailures

func (NoOp) OutboxFailures(string)

func (NoOp) RedeliverRequests

func (NoOp) RedeliverRequests(string)

func (NoOp) SetPublisherLag

func (NoOp) SetPublisherLag(float64)

Jump to

Keyboard shortcuts

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