Files
zeekay c3dc2f1ecf Read the event plane, not what it replaced
HIP-0132 unified o11y_logs, o11y_traces and o11y_metrics into one `event`
database and dropped them. The commit that restored the reads repointed
three files and said so; it was thirty. The rest went on naming databases
that no longer exist, so trace funnels, the Kafka and queue panels, the
v3/v4 logs and traces builders and the PromQL adapter each answered
Code: 81 UNKNOWN_DATABASE, and the golden tests agreed with them because
they pinned the same dead SQL.

pkg/telemetryplane is the one address for the name, imports nothing, and
is reachable from every depth that needs it. Its test walks the tree and
fails the build on a literal that names a dropped database, tests
included — a golden encoding broken SQL is a second vote for the bug, not
coverage.

Two service views turned a failed read into an offer to instrument an
already-instrumented application. A failure now shows the failure, and
onboarding is offered on a successful empty read.

Cherry-picked from salvage/blue-wt-o11y-readers 83ecbec03c.
2026-09-08 23:07:06 -07:00

73 lines
3.7 KiB
Go

// Package telemetryplane is the single answer to "which databases does this
// binary name?".
//
// WHY IT EXISTS. HIP-0132 unified the three SIGNAL databases — o11y_logs,
// o11y_traces, o11y_metrics — into one `event` database and dropped them. The
// commit that restored the reads (5be9208c4e, "o11y: read the event plane")
// pointed THREE files at `event` and said so in its own message:
//
// NOTE, deliberately left as-is: DBName is still a compile-time constant. It
// is now a CORRECT hardcode rather than a wrong one, but one name in three
// files is still three places to change.
//
// It was thirty files, not three. The other twenty-seven kept naming databases
// that had been dropped, so every read through them answered
// `Code: 81 ... UNKNOWN_DATABASE` — and the views on top of them rendered an
// error boundary, or worse a FALSE EMPTY that told the customer to instrument an
// already-instrumented application.
//
// This is that cut. A database name is a VALUE, so it has ONE address, and every
// layer can reach it because this package imports nothing. The signal packages,
// the legacy v3/v4 query builders, the Prometheus adapter and the query-service
// constants sit at four different depths and some of them are imported BY
// telemetrystore, so the constants cannot live there without a cycle.
//
// plane_test.go asserts that no OTHER file in the tree spells a database name.
// That assertion is the point of the package: a new hardcode fails the build
// instead of failing a customer's dashboard six weeks later.
package telemetryplane
// DBName is the telemetry plane: ONE database holding every signal —
// event.log, event.span, event.error and the metric tables. Every table in
// every signal is qualified by this and nothing else.
//
// It is a constant, not config: a deployment that pointed half its readers at a
// second database would be two planes wearing one name, and the failure mode is
// the silent one — half the rows.
const DBName = "event"
// THE DATABASES THAT ARE NOT THE PLANE.
//
// Listing them here is not an invitation to add more. It is what makes the
// question answerable: "the plane, and these four" is checkable, while a name
// spelled in whichever file happened to need it is not. Each has a live WRITER,
// which is the whole reason it was out of HIP-0132's scope — repointing a reader
// at `event` when the rows are still landing somewhere else is the same defect as
// reading a dropped database, pointed the other way.
//
// Each name is aliased by exactly one package, which owns its table names too:
//
// MetadataDBName -> telemetrymetadata (otel-collector metadata exporter writes it)
// MeterDBName -> telemetrymeter (metering/usage counters)
// AuditDBName -> telemetryaudit (audit trail; separate retention and gate)
// AnalyticsDBName -> implrulestatehistory (AddRuleStateHistory writes it)
//
// A name leaves this block by being MIGRATED — a writer moves, the rows move,
// the alias becomes DBName — never by being deleted.
const (
MetadataDBName = "o11y_metadata"
MeterDBName = "o11y_meter"
AuditDBName = "o11y_audit"
AnalyticsDBName = "o11y_analytics"
)
// Dropped names the three signal databases HIP-0132 removed. A read that names
// one answers Code: 81 UNKNOWN_DATABASE.
//
// They are HERE because a test proving a query does not name them has to spell
// them, and a name spelled in a test file is a name in the tree — which is the
// exact thing plane_test.go refuses. One address for the fact, and the refusal
// keeps its teeth: a golden that PINS a dropped name still fails, because it
// pins a literal rather than ranging over this.
var Dropped = []string{"o11y_logs", "o11y_traces", "o11y_metrics"}