Java Code Examples for com.codahale.metrics.MetricRegistry#removeMatching()
The following examples show how to use
com.codahale.metrics.MetricRegistry#removeMatching() .
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: RedisSessionRepository.java From HttpSessionReplacer with MIT License | 6 votes |
/** * This method starts a separate thread that listens to key expirations events. * * @param sessionManager */ @Override public void setSessionManager(final SessionManager sessionManager) { this.sessionManager = sessionManager; MetricRegistry metrics = sessionManager.getMetrics(); if (metrics != null) { // Cleanup old metrics related to this namespace metrics.removeMatching(new MetricFilter() { @Override public boolean matches(String name, Metric metric) { return name.startsWith(name(RedisConfiguration.METRIC_PREFIX, "redis")); } }); if (sticky) { failoverMetrics = metrics.meter(name(RedisConfiguration.METRIC_PREFIX, namespace, "redis", "failover")); } redis.startMonitoring(metrics); } expirationManager.startExpiredSessionsTask(sessionManager); }
Example 2
Source File: SolrMetricManager.java From lucene-solr with Apache License 2.0 | 6 votes |
public int unregisterGauges(String registryName, String tagSegment) { if (tagSegment == null) { return 0; } MetricRegistry registry = registry(registryName); if (registry == null) return 0; AtomicInteger removed = new AtomicInteger(); registry.removeMatching((name, metric) -> { if (metric instanceof GaugeWrapper) { @SuppressWarnings({"rawtypes"}) GaugeWrapper wrapper = (GaugeWrapper) metric; boolean toRemove = wrapper.getTag().contains(tagSegment); if (toRemove) { removed.incrementAndGet(); } return toRemove; } return false; }); return removed.get(); }
Example 3
Source File: RegistryHelper.java From vertx-dropwizard-metrics with Apache License 2.0 | 4 votes |
public static void shutdown(MetricRegistry registry) { registry.removeMatching((name, metric) -> true); }
Example 4
Source File: DropwizardHelper.java From okapi with Apache License 2.0 | 3 votes |
/** * Register a gauge. * That is, a number of some sort that gets polled at intervals, and * reported to Graphite. For example, the number of known modules. * Call like this: * DropwizardHelper.registerGauge("moduleCount", () -> modules.size()); * * @param key The key for the metric to report * @param g A Gauge with a lambda to get the value */ public static void registerGauge(String key, Gauge g) { try { MetricRegistry reg = SharedMetricRegistries.getOrCreate("okapi"); reg.removeMatching((String name, Metric metric) -> key.equals(name)); reg.register(key, g); } catch (Exception e) { logger.warn("registerGauge {}", e.getMessage(), e); } }