use of com.codahale.metrics.MetricFilter in project lucene-solr by apache.
the class MetricUtils method toMaps.
/**
* Convert selected metrics to maps or to flattened objects.
* @param registry source of metrics
* @param shouldMatchFilters metrics must match any of these filters
* @param mustMatchFilter metrics must match this filter
* @param propertyFilter limit what properties of a metric are returned
* @param skipHistograms discard any {@link Histogram}-s and histogram parts of {@link Timer}-s.
* @param skipAggregateValues discard internal values of {@link AggregateMetric}-s.
* @param compact use compact representation for counters and gauges.
* @param simple use simplified representation for complex metrics - instead of a (name, map)
* only the selected (name "." key, value) pairs will be produced.
* @param consumer consumer that accepts produced objects
*/
public static void toMaps(MetricRegistry registry, List<MetricFilter> shouldMatchFilters, MetricFilter mustMatchFilter, PropertyFilter propertyFilter, boolean skipHistograms, boolean skipAggregateValues, boolean compact, boolean simple, BiConsumer<String, Object> consumer) {
final Map<String, Metric> metrics = registry.getMetrics();
final SortedSet<String> names = registry.getNames();
names.stream().filter(s -> shouldMatchFilters.stream().anyMatch(metricFilter -> metricFilter.matches(s, metrics.get(s)))).filter(s -> mustMatchFilter.matches(s, metrics.get(s))).forEach(n -> {
Metric metric = metrics.get(n);
convertMetric(n, metric, propertyFilter, skipHistograms, skipAggregateValues, compact, simple, consumer);
});
}
use of com.codahale.metrics.MetricFilter in project incubator-gobblin by apache.
the class MetricContextTest method testGetMetricsWithFilter.
@Test(dependsOnMethods = "testGetMetrics")
@SuppressWarnings("unchecked")
public void testGetMetricsWithFilter() {
MetricFilter filter = new MetricFilter() {
@Override
public boolean matches(String name, Metric metric) {
return !name.equals(MetricContext.GOBBLIN_METRICS_NOTIFICATIONS_TIMER_NAME);
}
};
Map<String, Counter> counters = this.context.getCounters(filter);
Assert.assertEquals(counters.size(), 1);
Assert.assertTrue(counters.containsKey(RECORDS_PROCESSED));
Map<String, Meter> meters = this.context.getMeters(filter);
Assert.assertEquals(meters.size(), 1);
Assert.assertTrue(meters.containsKey(RECORD_PROCESS_RATE));
Map<String, Histogram> histograms = this.context.getHistograms(filter);
Assert.assertEquals(histograms.size(), 1);
Assert.assertTrue(histograms.containsKey(RECORD_SIZE_DISTRIBUTION));
Map<String, Timer> timers = this.context.getTimers(filter);
Assert.assertEquals(timers.size(), 1);
Assert.assertTrue(timers.containsKey(TOTAL_DURATION));
Map<String, Gauge> gauges = this.context.getGauges(filter);
Assert.assertEquals(gauges.size(), 1);
Assert.assertTrue(gauges.containsKey(QUEUE_SIZE));
}
use of com.codahale.metrics.MetricFilter in project jackrabbit-oak by apache.
the class BenchmarkRunner method reportMetrics.
private static void reportMetrics(StatisticsProvider statsProvider) {
if (statsProvider instanceof MetricStatisticsProvider) {
MetricRegistry metricRegistry = ((MetricStatisticsProvider) statsProvider).getRegistry();
ConsoleReporter.forRegistry(metricRegistry).outputTo(System.out).filter(new MetricFilter() {
@Override
public boolean matches(String name, Metric metric) {
if (metric instanceof Counting) {
// Only report non zero metrics
return ((Counting) metric).getCount() > 0;
}
return true;
}
}).build().report();
}
}
use of com.codahale.metrics.MetricFilter in project openscoring by openscoring.
the class ModelResource method undeploy.
@DELETE
@Path("{id:" + ModelRegistry.ID_REGEX + "}")
@RolesAllowed(value = { "admin" })
@Produces(MediaType.APPLICATION_JSON)
public SimpleResponse undeploy(@PathParam("id") String id) {
Model model = this.modelRegistry.get(id);
if (model == null) {
throw new NotFoundException("Model \"" + id + "\" not found");
}
boolean success = this.modelRegistry.remove(id, model);
if (!success) {
throw new InternalServerErrorException("Concurrent modification");
}
final String prefix = createNamePrefix(id);
MetricFilter filter = new MetricFilter() {
@Override
public boolean matches(String name, Metric metric) {
return name.startsWith(prefix);
}
};
this.metricRegistry.removeMatching(filter);
SimpleResponse response = new SimpleResponse();
return response;
}
use of com.codahale.metrics.MetricFilter in project killbill by killbill.
the class CacheProviderBase method createCache.
<C extends Configuration> void createCache(final CacheManager cacheManager, final String cacheName, final C configuration) {
// Make sure we start from a clean state - this is mainly useful for tests
cacheManager.destroyCache(cacheName);
final Cache cache = cacheManager.createCache(cacheName, configuration);
Preconditions.checkState(!cache.isClosed(), "Cache '%s' should not be closed", cacheName);
// Re-create the metrics to support dynamically created caches (e.g. for Shiro)
metricRegistry.removeMatching(new MetricFilter() {
@Override
public boolean matches(final String name, final Metric metric) {
return name != null && name.startsWith(PROP_METRIC_REG_JCACHE_STATISTICS);
}
});
metricRegistry.register(PROP_METRIC_REG_JCACHE_STATISTICS, new JCacheGaugeSet());
}
Aggregations