BaseInit: Bind DisabledMetricMaker

In some cases a plugin may have an InitStep that refers to other
classes in its implementation, that in turn get a MetricMaker
injected.

Since the MetricMaker, among other things, is not available to
the InitStep, this results in a guice injection error during the
plugins init step of site initialization.

Bind the DisabledMetricMaker to avoid the injection error. This
has the result that the InitStep works, but no metrics can be
recorded. Update the metrics documentation to explicitly mention
that metrics are not available during plugin init steps.

Bug: Issue 5438
Change-Id: Iac9f462eb93a2ae668d5c934e61eda9f23bd3c4d
This commit is contained in:
David Pursehouse
2017-02-03 19:05:29 +09:00
parent 5e48cddbb3
commit 48d05ea980
2 changed files with 7 additions and 0 deletions

View File

@@ -2217,6 +2217,9 @@ Metric recording time spent on an operation.
+
Metric recording statistical distribution (rate) of values.
Note that metrics cannot be recorded from plugin init steps that
are run during site initialization.
Plugin metrics are recorded under `plugins/${plugin-name}/${metric-name}`.
See the replication metrics in the

View File

@@ -23,6 +23,8 @@ import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.gerrit.common.Die;
import com.google.gerrit.common.IoUtil;
import com.google.gerrit.metrics.DisabledMetricMaker;
import com.google.gerrit.metrics.MetricMaker;
import com.google.gerrit.pgm.init.api.ConsoleUI;
import com.google.gerrit.pgm.init.api.InitFlags;
import com.google.gerrit.pgm.init.api.InstallAllPlugins;
@@ -274,6 +276,8 @@ public class BaseInit extends SiteProgram {
LibraryDownload.class).toInstance(getSkippedDownloads());
bind(Boolean.class).annotatedWith(
LibraryDownload.class).toInstance(skipAllDownloads());
bind(MetricMaker.class).to(DisabledMetricMaker.class);
}
});