Documentation
¶
Overview ¶
Package pipestats implements model.StatsRecorder: it records per-query observability rows and flushes them to ClickHouse in batches via the shared CHInserter, mirroring the gatherer's max(N, interval) flush (ADR 0014). Recording is non-blocking — observability must never slow or block the query path, so a full buffer drops stats rather than applying backpressure.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Recorder)
Option configures a Recorder.
func WithBufferSize ¶
WithBufferSize sets the in-flight buffer capacity before Record drops (default 4096).
func WithFlushInterval ¶
WithFlushInterval sets the max time a stat waits before flushing (default 5s).
func WithFlushSize ¶
WithFlushSize sets the row count that triggers an early flush (default 1000).
func WithLogger ¶
WithLogger sets the slog logger (default: slog.Default).
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder buffers QueryStats and flushes them to ClickHouse. Build with New; the background flusher starts immediately. Call Close to drain on shutdown.
func New ¶
func New(ins model.CHInserter, opts ...Option) *Recorder
New builds a Recorder and starts its background flusher. ins writes the batched rows; the destination table is described by Schema().
func (*Recorder) Close ¶
Close stops the flusher and drains buffered stats, returning when the final flush completes or ctx expires. Safe to call once.
func (*Recorder) Record ¶
Record buffers a stat for async flush. It is non-blocking: if the buffer is full the stat is dropped (counted), never applying backpressure to the query path (ADR 0014 — best-effort observability).
ponytail: dropping is the intended overflow behavior; the dropped counter is in-memory only. A future build could expose it as a Prometheus gauge.
func (*Recorder) Schema ¶
func (r *Recorder) Schema() *model.Datasource
Schema returns the synthetic Datasource describing the pipe_stats table, so the orchestrator/deploy can EnsureTable it before the first flush.
ponytail: Tinybird writes to db `tinybird.pipe_stats`; the MVP writes to a `pipe_stats` table in the active workspace database. Promote to a dedicated `tinybird` database when system-table parity matters.