Add combinedRefsSha1 to metrics

Expose new metric providing a "combined refs SHA-1", which could be
used to ensure eventual consistency of repository refs.

It's based on the `Sha1AllRefs`[1] Groovy script, which will iterate
over all repository refs and combine them into a single SHA-1. Then the
resulting SHA-1 will be truncated to an integer value so that it can
be included in metrics.

Exposing this metric should enable Gerrit admins to detect potential
inconsistencies between nodes. All git repositories are **eventually
consistent** which means that detecting different values for combined
refs SHA-1 is **NOT** equivalent to data inconsistency. But not
reporting a consistent state (when the combined refs SHA-1 across nodes
is the same) for a _reasonable time_ should raise an eyebrow and lead to
an investigation if any of the replication events were lost.

The _reasonable time_ will differ from repository to repository, for
some it may be 2 hours, and for others 24 hours. Meaning, that within
that time the repositories should be consistent at least once. It's on
the Gerrit admin to find the time window that works best for their


Bug: Issue 324975825
Change-Id: I2e4dbea0892776069dea371803653b7dd239f7f8
5 files changed
tree: bb033e7558b139933e109cc873fa65ad8ae4d6eb
  1. src/
  2. .gitignore
  3. BUILD

Plugin to collect Git repository metrics

This plugin allows a systematic collection of repository metrics. Metrics are updated upon a ref-update receive.

How to build

Clone or link this plugin to the plugins directory of Gerrit‘s source tree, and then run bazel build on the plugin’s directory.


git clone --recursive
git clone
pushd gerrit/plugins && ln -s ../../git-repo-metrics . && popd
cd gerrit && bazel build plugins/git-repo-metrics

The output plugin jar is created in:


How to install

Copy the git-repo-metrics.jar into the Gerrit's /plugins directory and wait for the plugin to be automatically loaded.


More information about the plugin configuration can be found in the file.