SuperManifestRefUpdatedListener: Make commit latency timer cumulative
The supermanifest/superproject_commit_latency timer was created with a
Description that is neither cumulative nor has a unit. A Gerrit server
binds MetricMaker to DropWizardMetricMaker, which rejects such timers,
so constructing SuperManifestRefUpdatedListener fails and the plugin
is not loaded:
Cannot load plugin supermanifest
com.google.inject.ProvisionException: Unable to provision ...
Caused by: java.lang.IllegalArgumentException: timer must be cumulative
at ...SuperManifestRefUpdatedListener.<init>(SuperManifestRefUpdatedListener.java:149)
The acceptance tests don't catch this because their in-memory server
binds MetricMaker to TestMetricMaker, which doesn't validate metric
descriptions.
Mark the timer cumulative and give it the milliseconds unit, as
DropWizardMetricMaker requires for timers.
Change-Id: Ie22f661b3b7522b68145125705299253c3164f1e
diff --git a/java/com/googlesource/gerrit/plugins/supermanifest/SuperManifestRefUpdatedListener.java b/java/com/googlesource/gerrit/plugins/supermanifest/SuperManifestRefUpdatedListener.java
index efa5577..663d9a8 100644
--- a/java/com/googlesource/gerrit/plugins/supermanifest/SuperManifestRefUpdatedListener.java
+++ b/java/com/googlesource/gerrit/plugins/supermanifest/SuperManifestRefUpdatedListener.java
@@ -148,7 +148,9 @@
this.superprojectCommitTimer =
metrics.newTimer(
"supermanifest/superproject_commit_latency",
- new Description("Time taken to parse the manifest and update the superproject"),
+ new Description("Time taken to parse the manifest and update the superproject")
+ .setCumulative()
+ .setUnit(Description.Units.MILLISECONDS),
Field.ofEnum(
ConfigEntry.ToolType.class,
"tool",