Skip to content

stacklok.build_info exports as stacklok_build_info_ratio (drop WithUnit("1") upstream) #6170

Open

Description

@glageju

coremetrics.RegisterBuildInfo sets metric.WithUnit("1") ([email protected]/telemetry/metrics/buildinfo.go:50). The OTel Prometheus translator appends a unit suffix to a dimensionless gauge, so the metric exports as:

stacklok_build_info_ratio{commit="...",component="toolhive",version="..."} 1

Two problems:

  1. _ratio is semantically wrong. build_info is an identity gauge that always observes 1; the identity lives entirely in its labels. It is not a ratio. Prometheus convention for this shape is a bare *_build_info (go_build_info, node_exporter_build_info).
  2. The name is easy to get wrong in queries. A dashboard joining on stacklok_build_info returns empty. require.Contains(body, "stacklok_build_info") also passes on the suffixed name by substring, so a naive test asserts nothing — that bit us in Standardize proxy + vMCP metrics to stacklok.*, delete legacy twins #5956 (now anchored at line start).

Fix

Drop metric.WithUnit("1") in toolhive-core so the gauge exports unitless as stacklok_build_info, then bump the pin in toolhive and drop the (_ratio)? accommodation from the test regex and the docs note.

This cannot be fixed from the toolhive repo — RegisterBuildInfo lives in toolhive-core, so it needs a core release plus a pin bump here.

Interim

docs/observability.md documents the actual exported _ratio name so operators query something that exists. RFC §3.4 / AT #2 is satisfied either way (the gauge is present with component/version/commit); this is about the name customers will put in dashboards, so it's worth fixing before the vocabulary spreads.

Activity

  1. added
    needs-triage
    on Aug 1, 2026
  2. jhrozek commented on Nov 24, 2026

    @jhrozek
    Contributor

    Thanks for writing this up, and for the detail on the translator behaviour. I checked it. In the pinned toolhive-core (v0.0.60) the gauge is created with WithUnit("1"), and the pinned otlptranslator appends _ratio to gauges with that unit, so the exported name would be stacklok_build_info_ratio. Your point that it should be a bare *_build_info makes sense to me.

    One thing I can't match up: on current main I can't find anything that registers stacklok.build_info. It seems to have been part of #5956, which was closed without merging. Is that right? If so, I think the name fix belongs in toolhive-core first, and we pick it up when build_info is wired in here. Are you planning to reopen that work in a new PR, or should this issue just track the core change?

  3. removed
    needs-triage
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions