Java Code Examples for com.codahale.metrics.MetricRegistry#MetricSupplier

The following examples show how to use com.codahale.metrics.MetricRegistry#MetricSupplier . 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: MetricSuppliers.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/**
 * Create a {@link Counter} supplier.
 * @param loader resource loader
 * @param info plugin configuration, or null for default
 * @return configured supplier instance, or default instance if configuration was invalid
 */
@SuppressWarnings({"unchecked"})
public static MetricRegistry.MetricSupplier<Counter> counterSupplier(SolrResourceLoader loader, PluginInfo info) {
  if (info == null || info.className == null || info.className.trim().isEmpty()) {
    return new DefaultCounterSupplier();
  }

  MetricRegistry.MetricSupplier<Counter> supplier;
  try {
    supplier = loader.newInstance(info.className, MetricRegistry.MetricSupplier.class);
  } catch (Exception e) {
    log.warn("Error creating custom Counter supplier (will use default): {}", info, e);
    supplier = new DefaultCounterSupplier();
  }
  if (supplier instanceof PluginInfoInitialized) {
    ((PluginInfoInitialized)supplier).init(info);
  } else {
    SolrPluginUtils.invokeSetters(supplier, info.initArgs, true);
  }
  return supplier;
}
 
Example 2
Source File: MetricSuppliers.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/**
 * Create a {@link Meter} supplier.
 * @param loader resource loader
 * @param info plugin configuration, or null for default
 * @return configured supplier instance, or default instance if configuration was invalid
 */
@SuppressWarnings({"unchecked"})
public static MetricRegistry.MetricSupplier<Meter> meterSupplier(SolrResourceLoader loader, PluginInfo info) {
  MetricRegistry.MetricSupplier<Meter> supplier;
  if (info == null || info.className == null || info.className.isEmpty()) {
    supplier = new DefaultMeterSupplier();
  } else {
    try {
      supplier = loader.newInstance(info.className, MetricRegistry.MetricSupplier.class);
    } catch (Exception e) {
      log.warn("Error creating custom Meter supplier (will use default): {}",info, e);
      supplier = new DefaultMeterSupplier();
    }
  }
  if (supplier instanceof PluginInfoInitialized) {
    ((PluginInfoInitialized)supplier).init(info);
  } else {
    SolrPluginUtils.invokeSetters(supplier, info.initArgs, true);
  }
  return supplier;
}
 
Example 3
Source File: MetricSuppliers.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/**
 * Create a {@link Timer} supplier.
 * @param loader resource loader
 * @param info plugin configuration, or null for default
 * @return configured supplier instance, or default instance if configuration was invalid
 */
@SuppressWarnings({"unchecked"})
public static MetricRegistry.MetricSupplier<Timer> timerSupplier(SolrResourceLoader loader, PluginInfo info) {
  MetricRegistry.MetricSupplier<Timer> supplier;
  if (info == null || info.className == null || info.className.isEmpty()) {
    supplier = new DefaultTimerSupplier(loader);
  } else {
    try {
      supplier = loader.newInstance(info.className, MetricRegistry.MetricSupplier.class);
    } catch (Exception e) {
      log.warn("Error creating custom Timer supplier (will use default): {}", info, e);
      supplier = new DefaultTimerSupplier(loader);
    }
  }
  if (supplier instanceof PluginInfoInitialized) {
    ((PluginInfoInitialized)supplier).init(info);
  } else {
    SolrPluginUtils.invokeSetters(supplier, info.initArgs, true);
  }
  return supplier;
}
 
Example 4
Source File: MetricSuppliers.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/**
 * Create a {@link Histogram} supplier.
 * @param info plugin configuration, or null for default
 * @return configured supplier instance, or default instance if configuration was invalid
 */
@SuppressWarnings({"unchecked"})
public static MetricRegistry.MetricSupplier<Histogram> histogramSupplier(SolrResourceLoader loader, PluginInfo info) {
  MetricRegistry.MetricSupplier<Histogram> supplier;
  if (info == null || info.className == null || info.className.isEmpty()) {
    supplier = new DefaultHistogramSupplier(loader);
  } else {
    try {
      supplier = loader.newInstance(info.className, MetricRegistry.MetricSupplier.class);
    } catch (Exception e) {
      log.warn("Error creating custom Histogram supplier (will use default): {}", info, e);
      supplier = new DefaultHistogramSupplier(loader);
    }
  }
  if (supplier instanceof PluginInfoInitialized) {
    ((PluginInfoInitialized)supplier).init(info);
  } else {
    SolrPluginUtils.invokeSetters(supplier, info.initArgs, true);
  }
  return supplier;
}
 
Example 5
Source File: RaftLogMetrics.java    From incubator-ratis with Apache License 2.0 4 votes vote down vote up
public void addFlushBatchSizeGauge(MetricRegistry.MetricSupplier<Gauge> supplier) {
  registry.gauge(RAFT_LOG_SYNC_BATCH_SIZE, supplier);
}
 
Example 6
Source File: SolrMetricManager.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public MetricRegistry.MetricSupplier<Counter> getCounterSupplier() {
  return counterSupplier;
}
 
Example 7
Source File: SolrMetricManager.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public MetricRegistry.MetricSupplier<Meter> getMeterSupplier() {
  return meterSupplier;
}
 
Example 8
Source File: SolrMetricManager.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public MetricRegistry.MetricSupplier<Timer> getTimerSupplier() {
  return timerSupplier;
}
 
Example 9
Source File: SolrMetricManager.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public MetricRegistry.MetricSupplier<Histogram> getHistogramSupplier() {
  return histogramSupplier;
}
 
Example 10
Source File: MetricSuppliers.java    From feign with Apache License 2.0 4 votes vote down vote up
public MetricRegistry.MetricSupplier<Timer> timers() {
  // only keep timer data for 1 minute
  return () -> new Timer(new SlidingTimeWindowArrayReservoir(1, TimeUnit.MINUTES));
}
 
Example 11
Source File: MetricSuppliers.java    From feign with Apache License 2.0 4 votes vote down vote up
public MetricRegistry.MetricSupplier<Meter> meters() {
  return Meter::new;
}
 
Example 12
Source File: MetricSuppliers.java    From feign with Apache License 2.0 4 votes vote down vote up
public MetricRegistry.MetricSupplier<Histogram> histograms() {
  // only keep timer data for 1 minute
  return () -> new Histogram(new SlidingTimeWindowArrayReservoir(1, TimeUnit.MINUTES));
}
 
Example 13
Source File: RatisMetricRegistry.java    From incubator-ratis with Apache License 2.0 votes vote down vote up
Gauge gauge(String name, MetricRegistry.MetricSupplier<Gauge> supplier); 
Example 14
Source File: RatisMetricRegistry.java    From incubator-ratis with Apache License 2.0 votes vote down vote up
Timer timer(String name, MetricRegistry.MetricSupplier<Timer> supplier); 
Example 15
Source File: RatisMetricRegistry.java    From incubator-ratis with Apache License 2.0 votes vote down vote up
Counter counter(String name, MetricRegistry.MetricSupplier<Counter> supplier); 
Example 16
Source File: RatisMetricRegistry.java    From incubator-ratis with Apache License 2.0 votes vote down vote up
Meter meter(String name, MetricRegistry.MetricSupplier<Meter> supplier);