Java Code Examples for com.codahale.metrics.MetricFilter#ALL

The following examples show how to use com.codahale.metrics.MetricFilter#ALL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetricsConfigurator.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
@JsonCreator
public MetricsConfigurator(
    @JsonProperty("name") String name,
    @JsonProperty("comment") String comment,
    @JsonProperty("reporter") ReporterConfigurator reporter,
    @JsonProperty("includes") List<String> includes,
    @JsonProperty("excludes") List<String> excludes
    ) {
  super();
  this.name = Objects.requireNonNull(name, "All reporters must have a name");
  this.comment = comment;
  this.configurator = Objects.requireNonNull(reporter, () -> String.format("Invalid definition for reporter with name %s. Must define a reporter block.", name));
  this.includes = Optional.ofNullable(includes).orElse(Collections.emptyList());
  this.excludes = Optional.ofNullable(excludes).orElse(Collections.emptyList());

  if (this.includes.isEmpty() && this.excludes.isEmpty()) {
    filter = MetricFilter.ALL;
  } else {
    filter = new IncludesExcludesFilter(includes, excludes);
  }

}
 
Example 2
Source File: SpectatorReporter.java    From spectator with Apache License 2.0 6 votes vote down vote up
/** Create a new instance. */
SpectatorReporter(
    MetricRegistry metricRegistry,
    Registry spectatorRegistry,
    NameFunction nameFunction,
    ValueFunction valueFunction,
    Pattern gaugeCounters) {
  super(metricRegistry,
      "spectator",       // name
      MetricFilter.ALL,  // filter
      TimeUnit.SECONDS,  // rateUnit
      TimeUnit.SECONDS); // durationUnit
  this.spectatorRegistry = spectatorRegistry;
  this.nameFunction = nameFunction;
  this.valueFunction = valueFunction;
  this.gaugeCounters = gaugeCounters;
}
 
Example 3
Source File: DatadogMetricsReporter.java    From hudi with Apache License 2.0 6 votes vote down vote up
public DatadogMetricsReporter(HoodieWriteConfig config, MetricRegistry registry) {
  reportPeriodSeconds = config.getDatadogReportPeriodSeconds();
  ApiSite apiSite = config.getDatadogApiSite();
  String apiKey = config.getDatadogApiKey();
  ValidationUtils.checkState(!StringUtils.isNullOrEmpty(apiKey),
      "Datadog cannot be initialized: API key is null or empty.");
  boolean skipValidation = config.getDatadogApiKeySkipValidation();
  int timeoutSeconds = config.getDatadogApiTimeoutSeconds();
  String prefix = config.getDatadogMetricPrefix();
  ValidationUtils.checkState(!StringUtils.isNullOrEmpty(prefix),
      "Datadog cannot be initialized: Metric prefix is null or empty.");
  Option<String> host = Option.ofNullable(config.getDatadogMetricHost());
  List<String> tagList = config.getDatadogMetricTags();
  Option<List<String>> tags = tagList.isEmpty() ? Option.empty() : Option.of(tagList);

  reporter = new DatadogReporter(
      registry,
      new DatadogHttpClient(apiSite, apiKey, skipValidation, timeoutSeconds),
      prefix,
      host,
      tags,
      MetricFilter.ALL,
      TimeUnit.SECONDS,
      TimeUnit.SECONDS
  );
}
 
Example 4
Source File: ScheduledReporter.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
private MetricFilter createMetricFilter(Config config) {
  if (config.hasPath(METRIC_FILTER_NAME_REGEX) && config.hasPath(METRIC_FILTER_TYPE_LIST)) {
    return MetricFilters.and(new MetricNameRegexFilter(config.getString(METRIC_FILTER_NAME_REGEX)),
        new MetricTypeFilter(config.getString(METRIC_FILTER_TYPE_LIST)));
  }
  if (config.hasPath(METRIC_FILTER_NAME_REGEX)) {
    return new MetricNameRegexFilter(config.getString(METRIC_FILTER_NAME_REGEX));
  }
  if (config.hasPath(METRIC_FILTER_TYPE_LIST)) {
    return new MetricTypeFilter(config.getString(METRIC_FILTER_TYPE_LIST));
  }
  return MetricFilter.ALL;
}
 
Example 5
Source File: SolrMetricManager.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieve matching metrics and their names.
 *
 * @param registry     registry name.
 * @param metricFilter filter (null is equivalent to {@link MetricFilter#ALL}).
 * @return map of matching names and metrics
 */
public Map<String, Metric> getMetrics(String registry, MetricFilter metricFilter) {
  if (metricFilter == null || metricFilter == MetricFilter.ALL) {
    return registry(registry).getMetrics();
  }
  return registry(registry).getMetrics().entrySet().stream()
      .filter(entry -> metricFilter.matches(entry.getKey(), entry.getValue()))
      .collect(Collectors.toMap(entry -> entry.getKey(), entry -> entry.getValue()));
}
 
Example 6
Source File: NewtsReporter.java    From newts with Apache License 2.0 5 votes vote down vote up
private Builder(MetricRegistry registry) {
    this.registry = registry;
    this.rateUnit = TimeUnit.SECONDS;
    this.durationUnit = TimeUnit.MILLISECONDS;
    this.clock = Clock.defaultClock();
    this.filter = MetricFilter.ALL;
}
 
Example 7
Source File: CloudWatchReporter.java    From codahale-aggregated-metrics-cloudwatch-reporter with MIT License 5 votes vote down vote up
private Builder(final MetricRegistry metricRegistry, final CloudWatchAsyncClient cloudWatchAsyncClient, final String namespace) {
    this.metricRegistry = metricRegistry;
    this.cloudWatchAsyncClient = cloudWatchAsyncClient;
    this.namespace = namespace;
    this.percentiles = new Percentile[]{Percentile.P75, Percentile.P95, Percentile.P999};
    this.metricFilter = MetricFilter.ALL;
    this.rateUnit = TimeUnit.SECONDS;
    this.durationUnit = TimeUnit.MILLISECONDS;
    this.globalDimensions = new LinkedHashSet<>();
    this.cwMeterUnit = Optional.empty();
    this.cwRateUnit = toStandardUnit(rateUnit);
    this.cwDurationUnit = toStandardUnit(durationUnit);
    this.clock = Clock.defaultClock();
}
 
Example 8
Source File: CustomMetricsReporter.java    From cf-java-logging-support with Apache License 2.0 5 votes vote down vote up
private static MetricFilter getFilter(final List<String> whitelistMetrics) {
    if (whitelistMetrics == null || whitelistMetrics.isEmpty()) {
        return MetricFilter.ALL;
    }
    return new MetricFilter() {
        @Override
        public boolean matches(String name, com.codahale.metrics.Metric metric) {
            return whitelistMetrics.contains(name);
        }
    };
}
 
Example 9
Source File: ElasticsearchReporter.java    From oneops with Apache License 2.0 5 votes vote down vote up
private Builder(MetricRegistry registry) {
    this.registry = registry;
    this.clock = Clock.defaultClock();
    this.prefix = null;
    this.rateUnit = TimeUnit.SECONDS;
    this.durationUnit = TimeUnit.MILLISECONDS;
    this.filter = MetricFilter.ALL;
}
 
Example 10
Source File: MqMetricReporter.java    From pmq with Apache License 2.0 5 votes vote down vote up
private Builder(MetricRegistry registry) {
    this.registry = registry;
    this.rateUnit = TimeUnit.MILLISECONDS;
    this.durationUnit = TimeUnit.MILLISECONDS;
    this.filter = MetricFilter.ALL;
    this.tags = new HashMap<>();
}
 
Example 11
Source File: MqMetricReporter.java    From pmq with Apache License 2.0 5 votes vote down vote up
private Builder(MetricRegistry registry) {
    this.registry = registry;
    this.rateUnit = TimeUnit.MILLISECONDS;
    this.durationUnit = TimeUnit.MILLISECONDS;
    this.filter = MetricFilter.ALL;
    this.tags = new HashMap<>();
}
 
Example 12
Source File: MetricReporter.java    From sofa-jraft with Apache License 2.0 5 votes vote down vote up
private Builder(MetricRegistry registry) {
    this.registry = registry;
    this.prefix = "";
    this.output = System.out;
    this.locale = Locale.getDefault();
    this.clock = Clock.defaultClock();
    this.timeZone = TimeZone.getDefault();
    this.rateUnit = TimeUnit.SECONDS;
    this.durationUnit = TimeUnit.MILLISECONDS;
    this.filter = MetricFilter.ALL;
    this.disabledMetricAttributes = Collections.emptySet();
}
 
Example 13
Source File: ServerReporter.java    From hugegraph with Apache License 2.0 4 votes vote down vote up
private ServerReporter(MetricRegistry registry) {
    this(registry, SECONDS, MILLISECONDS, MetricFilter.ALL);
}
 
Example 14
Source File: WavefrontMetricsReporter.java    From dropwizard-wavefront with Apache License 2.0 4 votes vote down vote up
private Builder(MetricRegistry registry) {
  this.registry     = registry;
  this.rateUnit     = TimeUnit.SECONDS;
  this.durationUnit = TimeUnit.MILLISECONDS;
  this.filter       = MetricFilter.ALL;
}
 
Example 15
Source File: MetricsModule.java    From hugegraph with Apache License 2.0 4 votes vote down vote up
public MetricsModule(TimeUnit rateUnit, TimeUnit durationUnit,
                     boolean showSamples) {
    this(rateUnit, durationUnit, showSamples, MetricFilter.ALL);
}
 
Example 16
Source File: HadoopMetrics2Reporter.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
private Builder(MetricRegistry registry) {
    this.registry = registry;
    this.filter = MetricFilter.ALL;
    this.rateUnit = TimeUnit.SECONDS;
    this.durationUnit = TimeUnit.MILLISECONDS;
}
 
Example 17
Source File: NakadiMetricsServlet.java    From nakadi with MIT License 4 votes vote down vote up
/**
 * Returns the {@link MetricFilter} that shall be used to filter metrics, or {@link MetricFilter#ALL} if
 * the default should be used.
 */
protected MetricFilter getMetricFilter() {
    // use the default
    return MetricFilter.ALL;
}
 
Example 18
Source File: MqMeticReporterService.java    From pmq with Apache License 2.0 4 votes vote down vote up
private MqMeticReporterService(IMqClientBase mqClientBase) {
	reporter = new MqMetricReporter(MetricSingleton.getMetricRegistry(), "mq-client", MetricFilter.ALL,
			TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS, null, mqClientBase.getContext());
}
 
Example 19
Source File: MetricReportReporter.java    From incubator-gobblin with Apache License 2.0 4 votes vote down vote up
protected Builder() {
  super();
  this.name = "MetricReportReporter";
  this.filter = MetricFilter.ALL;
}
 
Example 20
Source File: SolrReporter.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
/**
 * Create a SolrReporter instance.
 * @param solrClientCache client cache to use for constructing SolrClient instances.
 * @param urlProvider what URL to send to.
 * @param metricManager metric manager
 * @param metrics metric specifications to report
 * @param handler handler name to report to
 * @param reporterId my reporter id
 * @param rateUnit rate unit
 * @param durationUnit duration unit
 * @param params request parameters
 * @param skipHistograms if true then don't send histogram metrics
 * @param skipAggregateValues if true then don't send aggregate metrics' individual values
 * @param cloudClient if true then use CloudSolrClient, plain HttpSolrClient otherwise.
 * @param compact if true then use compact representation.
 */
public SolrReporter(SolrClientCache solrClientCache, boolean closeClientCache,
                    Supplier<String> urlProvider, SolrMetricManager metricManager,
                    List<Report> metrics, String handler,
                    String reporterId, TimeUnit rateUnit, TimeUnit durationUnit,
                    SolrParams params, boolean skipHistograms, boolean skipAggregateValues,
                    boolean cloudClient, boolean compact) {
  super(dummyRegistry, "solr-reporter", MetricFilter.ALL, rateUnit, durationUnit, null, true);

  this.metricManager = metricManager;
  this.urlProvider = urlProvider;
  this.reporterId = reporterId;
  if (handler == null) {
    handler = MetricsCollectorHandler.HANDLER_PATH;
  }
  this.handler = handler;
  this.clientCache = solrClientCache;
  this.closeClientCache = closeClientCache;
  this.compiledReports = new ArrayList<>();
  metrics.forEach(report -> {
    MetricFilter filter = new SolrMetricManager.RegexFilter(report.metricFilters);
    try {
      CompiledReport cs = new CompiledReport(report);
      compiledReports.add(cs);
    } catch (PatternSyntaxException e) {
      log.warn("Skipping report with invalid registryPattern: {}", report.registryPattern, e);
    }
  });
  this.skipHistograms = skipHistograms;
  this.skipAggregateValues = skipAggregateValues;
  this.cloudClient = cloudClient;
  this.compact = compact;
  this.params = new ModifiableSolrParams();
  this.params.set(REPORTER_ID, reporterId);
  // allow overrides to take precedence
  if (params != null) {
    this.params.add(params);
  }
  metadata = new HashMap<>();
  metadata.put(REPORTER_ID, reporterId);
}