0647 — First-class metrics use one declaration catalog
Edit this pagePosted: 2026-09-08 · Report this thread
Superseded in part by [0648].
Context
The client needs live resource snapshots, retained metric history, and a catalog that says which Vulkan metrics exist before collection. The existing diagnostic registry declares only consumer-session counters; the collector’s other metrics are string constants that repeat kind and unit at production. [0569] established the right registry but not resource scope, attribute keys, or catalog growth across subjects.
Decision
diagnostic.DiagnosticMetricremains the concrete VK-coded declaration in the one diagnostic registry. It gains scope and ordered attribute keys; kind, unit, and scope remain strings there to preserve the infrastructure dependency direction.pkg/metricsowns every declaration instance and exposes typedMetricDefinition,MetricScope,MetricKind, andMetricUnitviews. Definitions are defensive values derived fromdiagnostic.Metrics(), never a second registry.- Metric declarations split by subject into
*_metrics.gofiles beside the worker, schedule, alert, topic, consumer-group, and consumer-session models. One conventions walk still verifies every code and every typed field. System().Metrics()lists all built-in definitions and all retained series; Topic and Group metrics handles list their applicable built-ins and expose typed selectors.System().Metrics().Metric(name, attributes)is the one arbitrary series selector.Snapshotreads live source tables.LatestandHistoryreturn bareMeasurementvalues from retained collection, always includingAt; newest retained does not mean fresh.
Consequences
- A new built-in metric has one declaration feeding collection, selectors, definitions, explain output, and Prometheus help.
- The former gauge-name constants become declaration pointers. A direct
pkg/metricscaller usesMetricCursorBacklog.Name; thepkg/vulkansurface had not exported those constants. - User metrics appear in retained reads but not definitions until durable user declarations settle separately.
- This supersedes [0569]‘s five-field metric declaration. Its shared registry, plain diagnostic strings, code-free wire measurement, session flush, and split live/retained reads remain unchanged.