Documentation
¶
Index ¶
- Constants
- Variables
- func CreateCacheTables(db *sql.DB) error
- func CreateParquetViews(db *sql.DB, parquetDir string) error
- func CreateViews(db *sql.DB) error
- func NormalizeJSON(text string) string
- func NormalizeLogQualifiers(node map[string]any)
- func PatternParams(value any) map[string]bool
- type Duck
- func (d *Duck) CheckpointHealth() (lastOK, lastAt time.Time, consecutiveFailures int, lastErr error)
- func (d *Duck) Close() error
- func (d *Duck) CompletedServiceRollupMinute(ctx context.Context) (time.Time, error)
- func (d *Duck) DefaultNamespace() string
- func (d *Duck) DrainVersionRollup(ctx context.Context) (int64, bool, error)
- func (d *Duck) Fatal() <-chan error
- func (d *Duck) Live(ctx context.Context) error
- func (d *Duck) MaintenanceHealth() (lastOK, lastAt time.Time, consecutiveFailures int, lastErr error)
- func (d *Duck) Overruns() int
- func (d *Duck) ParseSQL(ctx context.Context, query string) (map[string]any, error)
- func (d *Duck) Ping(ctx context.Context) error
- func (d *Duck) PrepareTelemetrySQL(ctx context.Context, query, describe string, maxRows int) (string, []bool, error)
- func (d *Duck) PublishParquet(ctx context.Context, publish func(context.Context) error) error
- func (d *Duck) PublishParquetReplacement(ctx context.Context, output telemetry.BatchMetadata, inputs []string, ...) error
- func (d *Duck) QueryContext(ctx context.Context, query string, args ...any) (queryrows.Rows, error)
- func (d *Duck) QueryRowScan(ctx context.Context, dest []any, query string, args ...any) error
- func (d *Duck) ReadConnections() int
- func (d *Duck) RecordAnomalies(ctx context.Context, findings []annotations.Anomaly, now time.Time) error
- func (d *Duck) RefreshDashboardRollups(ctx context.Context) (int64, error)
- func (d *Duck) RefreshReadCaches(ctx context.Context) (int64, error)
- func (d *Duck) RefreshVersionRollup(ctx context.Context) (int64, error)
- func (d *Duck) RenderSQL(ctx context.Context, node map[string]any) (string, error)
- func (d *Duck) RollupWatermark(ctx context.Context) (time.Time, error)
- func (d *Duck) RunRollups(ctx context.Context)
- func (d *Duck) SetReadPressure(pressure func() bool)
- func (d *Duck) SnapshotCacheStats() (hits, misses int64)
- func (d *Duck) Stalled() bool
- func (d *Duck) Trace(ctx context.Context, query telemetry.TraceQuery) ([]telemetry.IndexedSpan, telemetry.TraceTotals, error)
- func (d *Duck) TraceDetail(ctx context.Context, query telemetry.TraceQuery) (telemetry.TraceDetail, error)
- func (d *Duck) TraceSummaries(ctx context.Context, ids []telemetry.TraceIdentity, start, end int64) ([]telemetry.TraceTotals, error)
- func (d *Duck) Watch(ctx context.Context)
- func (d *Duck) WithReadTransaction(ctx context.Context, read func(queryrows.Queryer) error) error
- func (d *Duck) WriteGate() *writegate.Gate
Constants ¶
const MaxPatternBytes = 256
MaxPatternBytes bounds a pattern's length.
Variables ¶
var ErrStalled = errors.New("query engine stalled")
ErrStalled reports a stall in work Pitot owns: a Parquet publication running far past its budget, or an idle engine that does not answer a ping. Only a restart frees it.
Functions ¶
func CreateCacheTables ¶
CreateCacheTables creates DuckDB's tables: the rebuildable read caches and the anomaly history. The telemetry rows themselves live in immutable Parquet batches.
func CreateParquetViews ¶
CreateParquetViews exposes the fixed format-6 schema. Binding one file rather than unioning every footer bounds binder memory. Supplying a schema MAP suppresses DuckDB 2's VARIANT extraction pushdown, so read the physical schema directly; startup rejects mismatched batch schemas before this point. The bound file is the schema batch, listed first: a retired batch may be deleted between DuckDB's glob expansion and its bind. Reads of these views are bound to the captured catalog whenever it is not empty.
func CreateViews ¶
CreateViews creates stable clean-name views plus the attr() macro.
func NormalizeJSON ¶
NormalizeJSON makes the JSON text of a serialized column parseable. DuckDB writes nonfinite doubles as bare NaN, Infinity and -Infinity, which JSON cannot encode; they become the ProtoJSON strings of the same names. Storage remains typed.
func NormalizeLogQualifiers ¶
NormalizeLogQualifiers binds approved schema-qualified log columns before the panel replaces logs with its redacted projection. Snapshot compilation uses the same lexical resolver for every relation it replaces.
func PatternParams ¶
PatternParams names the parameters a statement uses as patterns, so a caller can bound their values when it binds them.
Types ¶
type Duck ¶
type Duck struct {
// DB is the read pool. Reads scan immutable Parquet concurrently, so it is
// sized from the machine.
DB *sql.DB
// contains filtered or unexported fields
}
func NewDuck ¶
func NewDuck(ctx context.Context, cfg config.Config, repository *telemetrystore.Repository) (*Duck, error)
func (*Duck) CheckpointHealth ¶
func (d *Duck) CheckpointHealth() (lastOK, lastAt time.Time, consecutiveFailures int, lastErr error)
CheckpointHealth reports the rollup-cache checkpoint's own health, mirroring MaintenanceHealth: when a fold last succeeded, when one was last attempted, how many have failed in a row, and the most recent error (nil after a clean fold). It is surfaced via /readyz separately from maintenance so a transient refusal — retried on the 10s compaction cycle — does not degrade readiness, while a fold that keeps failing well past that cadence still does. A zero lastAt means no checkpoint has been attempted since the process started.
func (*Duck) CompletedServiceRollupMinute ¶
CompletedServiceRollupMinute is the exclusive end of detector input. The minute containing the ingest watermark may still be incomplete.
func (*Duck) DefaultNamespace ¶
DefaultNamespace returns empty string so queries search all namespaces.
func (*Duck) DrainVersionRollup ¶
DrainVersionRollup repeats passes while a pass's budget left batches behind, and reports whether a backlog still remains when the phase budget ends.
func (*Duck) Fatal ¶
Fatal delivers the first fatal engine error a background pass saw. DuckDB has invalidated the database by then and fails every later statement, so the process must restart; nothing in it can recover the instance.
func (*Duck) Live ¶
Live reports whether the engine can still serve. A stall fails it. A pool where statements returned recently is alive. Otherwise a ping confirms it, and a ping that fails while reads hold the pool may only have waited for them, not found the engine hung, so that is alive too.
func (*Duck) MaintenanceHealth ¶
func (d *Duck) MaintenanceHealth() (lastOK, lastAt time.Time, consecutiveFailures int, lastErr error)
MaintenanceHealth reports the maintenance loop's own health: when it last completed cleanly, when a pass last executed at all (throttled calls don't count), and the error from the most recent executed pass (nil after a clean one). Surfaced via /readyz so an instance whose retention/compaction is failing — and therefore re-entering the storage growth spiral — tells its operator instead of only logging. lastAt distinguishes "failing right now" from a stale error awaiting the hourly retry; a zero lastAt means no pass has executed since the process started.
func (*Duck) Overruns ¶
Overruns counts the reads still running more than overrunGrace past their deadlines. They make readiness degraded, never liveness: a costly query holds its own connection while the engine serves the rest.
func (*Duck) ParseSQL ¶
ParseSQL parses one statement with DuckDB's parser and returns its serialized node. It reads no telemetry and takes no snapshot.
func (*Duck) Ping ¶
Ping runs a trivial statement on the read pool, recording progress when it answers. It is not tracked as a statement in flight; the connection it holds is counted in pings.
func (*Duck) PrepareTelemetrySQL ¶
func (d *Duck) PrepareTelemetrySQL(ctx context.Context, query, describe string, maxRows int) (string, []bool, error)
PrepareTelemetrySQL checks one untrusted SELECT (both query and describe, since binding describe can invoke table functions) against the telemetry SQL rules and wraps it in the projection that keeps nested values away from the Go driver. describe is the same statement with every placeholder replaced by NULL, which DESCRIBE can bind; the returned statement keeps query's placeholders and is run with QueryContext under the panel's read window.
func (*Duck) PublishParquet ¶
PublishParquet runs one catalog swap. Readers are never excluded or waited for: the swap is atomic under the catalog lock, and what it replaces stays on disk until no pinned reader can open it. The budget only bounds the swap's own publish gate, rename and fsync.
func (*Duck) PublishParquetReplacement ¶
func (d *Duck) PublishParquetReplacement(ctx context.Context, output telemetry.BatchMetadata, inputs []string, publish func(context.Context) error) error
PublishParquetReplacement reuses complete input caches when the SQL leases are idle. Busy leases defer the transfer to the refresh worker, without delaying the catalog swap or decoding the output again.
func (*Duck) QueryContext ¶
QueryContext executes a read against immutable Parquet files and DuckDB's local rollup cache.
func (*Duck) QueryRowScan ¶
QueryRowScan executes a single-row query against immutable Parquet files and DuckDB's local rollup cache.
func (*Duck) ReadConnections ¶
ReadConnections is the size of the read pool, so a caller can admit no more concurrent readers than there are connections.
func (*Duck) RecordAnomalies ¶
func (*Duck) RefreshDashboardRollups ¶
RefreshDashboardRollups advances the analytical dashboard summaries. Each pass commits a complete set of affected service-minutes and its ingest horizon.
func (*Duck) RefreshReadCaches ¶
RefreshReadCaches acknowledges complete immutable files, not an ingest-time watermark. A pass only aggregates its selected batches: it never rebuilds a retained-history index. Contributions and acknowledgements commit together.
func (*Duck) RefreshVersionRollup ¶
func (*Duck) RenderSQL ¶
RenderSQL renders a statement node (as returned by ParseSQL) back to SQL text with DuckDB's own serializer. The text is canonical: comments, dollar quotes and other lexical forms the author used cannot survive it, so a caller that checked the node can bind and run the rendering instead of the author's text.
func (*Duck) RollupWatermark ¶
RollupWatermark is the committed ingest horizon shared by service_rollup and span_rollup. This standalone preflight precedes the panel's data snapshot; snapshot-bound coverage checks read persisted state in their own transaction.
func (*Duck) RunRollups ¶
func (*Duck) SetReadPressure ¶
SetReadPressure connects foreground admission to bounded background yielding.
func (*Duck) SnapshotCacheStats ¶
SnapshotCacheStats reports the cumulative snapshot-compile cache hits and misses since start. A miss is a statement whose compiled relation aliases had to be built; a hit reused them. It lets a benchmark or test measure the cache hit rate, which window-stable statement text is meant to raise.
func (*Duck) Stalled ¶
Stalled reports whether a Parquet publication has run for publishStall: storage has stopped serving its rename or fsync.
func (*Duck) Trace ¶
func (d *Duck) Trace(ctx context.Context, query telemetry.TraceQuery) ([]telemetry.IndexedSpan, telemetry.TraceTotals, error)
Trace pins the immutable Parquet snapshot for the full indexed-file read.
func (*Duck) TraceDetail ¶
func (d *Duck) TraceDetail(ctx context.Context, query telemetry.TraceQuery) (telemetry.TraceDetail, error)
TraceDetail pins one snapshot for a trace's spans and logs together.
func (*Duck) TraceSummaries ¶
func (d *Duck) TraceSummaries(ctx context.Context, ids []telemetry.TraceIdentity, start, end int64) ([]telemetry.TraceTotals, error)
TraceSummaries pins one snapshot for the bounded multi-trace root pass.
func (*Duck) Watch ¶
Watch reports read overruns, and delivers ErrStalled on Fatal once a stall in Pitot's own work has lasted stallExit, so the process exits and its supervisor restarts it. Overload and costly queries are no stall. It stops with ctx, so shutdown cannot fire it.
func (*Duck) WithReadTransaction ¶
WithReadTransaction keeps derived annotation rows and completeness flags in one read snapshot. Its callback only receives the query surface.
Source Files
¶
- annotations.go
- batch_cache.go
- cache_transfer.go
- dashboard_rollup.go
- duck.go
- duck_memory.go
- edge_messaging.go
- edge_peers.go
- file_snapshot.go
- json_result.go
- metric_names.go
- panel_sql.go
- progress.go
- receiver_entity_rollup.go
- receiver_rollup.go
- resource_inventory.go
- sql_boundary.go
- sql_keys.go
- sql_qualifiers.go
- trace_exemplars.go
- views.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package querytest builds mutable fixtures; production reads immutable Parquet.
|
Package querytest builds mutable fixtures; production reads immutable Parquet. |
|
Package writegate serializes and measures writes to DuckDB's rebuildable rollup cache.
|
Package writegate serializes and measures writes to DuckDB's rebuildable rollup cache. |