public GerritPrometheusExporter()

in src/main/java/com/googlesource/gerrit/plugins/metricsreporterprometheus/GerritPrometheusExporter.java [50:72]


  public GerritPrometheusExporter(
      MetricRegistry registry,
      CapabilityChecker capabilityChecker,
      PluginConfigFactory cfgFactory,
      @PluginName String pluginName) {
    this.capabilityChecker = capabilityChecker;
    this.prometheusBearerToken =
        cfgFactory.getFromGerritConfig(pluginName).getString(PROMETHEUS_BEARER_TOKEN);
    this.gerritBuildInfoMetric = new GerritBuildInformationMetric();

    List<Pattern> excludes =
        Arrays.stream(cfgFactory.getFromGerritConfig(pluginName).getStringList(EXCLUDE_KEY))
            .map(Pattern::compile)
            .collect(toList());

    FilteredMetricRegistry filteredRegistry =
        new FilteredMetricRegistry(
            registry, s -> excludes.stream().anyMatch(e -> e.matcher(s).matches()));

    // Hook the Dropwizard registry into the Prometheus registry
    // via the DropwizardExports collector.
    CollectorRegistry.defaultRegistry.register(new DropwizardExports(filteredRegistry));
  }