Skip to content

counter: Key metric on storage path instead of name

Will Chandler (ex-GitLab) requested to merge wc/repo-count-dedup into master

On dotcom each Gitaly server is configured with all storages know to rails, with each using the same path. In practice only on storage will be sent to the host, but this allows us to keep the config identical across all Gitaly servers.

Currently RepositoryCounter will walk each storage configured on startup, which is causing each Gitaly server to generate <STORAGE_CT>-1 duplicate values and creating very high cardinality on the gitaly_total_repository_count metric.

To resolve this, we switch the metric key from the storage name over to its path, which will always be unique on a given server.

We now find the unique paths when constructing the RepositoryCounter object, and also store a map of storage name to paths as inserts now require us to convert the storage name to its path.

Also, fix context incorrectly being shadowed.

Related to https://gitlab.com/gitlab-org/gitaly/-/issues/5400

Edited by Will Chandler (ex-GitLab)

Merge request reports