Skip to content

Refactor Prometheus usage to explicitly pass a registry #2829

Open

Description

@tstirrat15

We're currently implicitly using the default registry, which means that tests sometimes flake because two different tests attempt to add the same metric to the same registry, and there's functionality where you can explicitly set up and pass a registry: https://pkg.go.dev/github.com/prometheus/client_golang/prometheus#hdr-Advanced_Uses_of_the_Registry

If we moved to that approach, we could have each test provide its own registry and avoid duplicate registration.

Activity

  1. tstirrat15 commented on Jan 28, 2026

    @tstirrat15
    ContributorAuthor

    This may mean we can't use promauto. Hopefully that isn't too big an issue.

  2. added theissue type on Jan 29, 2026
  3. miparnisari commented on Feb 13, 2026

    @miparnisari
    Contributor

    Slightly related: a side effect of registering metrics inside func init() is that if you run SpiceDB against Spanner (for example, via docker-compose -f docker-compose.spanner.yaml up --build), you can still see CRDB metrics in http://localhost:9090/metrics. (With zero value, but still...)

    # HELP crdb_client_resets cockroachdb client-side tx reset distribution
    # TYPE crdb_client_resets histogram
    crdb_client_resets_bucket{le="0"} 0
    crdb_client_resets_bucket{le="1"} 0
    crdb_client_resets_bucket{le="2"} 0
    crdb_client_resets_bucket{le="5"} 0
    crdb_client_resets_bucket{le="10"} 0
    crdb_client_resets_bucket{le="20"} 0
    crdb_client_resets_bucket{le="50"} 0
    crdb_client_resets_bucket{le="+Inf"} 0
    crdb_client_resets_sum 0
    crdb_client_resets_count 0
    # HELP crdb_healthy_nodes the number of healthy crdb nodes detected by spicedb
    # TYPE crdb_healthy_nodes gauge
    crdb_healthy_nodes 0
    
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

    kind/tech debtAddresses legacy code/decisions

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions