/** {@inheritDoc} */ @Override public void close() { registry.remove(MetricRegistry.name(poolName, METRIC_CATEGORY, METRIC_NAME_WAIT)); registry.remove(MetricRegistry.name(poolName, METRIC_CATEGORY, METRIC_NAME_USAGE)); registry.remove(MetricRegistry.name(poolName, METRIC_CATEGORY, METRIC_NAME_CONNECT)); registry.remove(MetricRegistry.name(poolName, METRIC_CATEGORY, METRIC_NAME_TIMEOUT_RATE)); registry.remove(MetricRegistry.name(poolName, METRIC_CATEGORY, METRIC_NAME_TOTAL_CONNECTIONS)); registry.remove(MetricRegistry.name(poolName, METRIC_CATEGORY, METRIC_NAME_IDLE_CONNECTIONS)); registry.remove(MetricRegistry.name(poolName, METRIC_CATEGORY, METRIC_NAME_ACTIVE_CONNECTIONS)); registry.remove(MetricRegistry.name(poolName, METRIC_CATEGORY, METRIC_NAME_PENDING_CONNECTIONS)); registry.remove(MetricRegistry.name(poolName, METRIC_CATEGORY, METRIC_NAME_MAX_CONNECTIONS)); registry.remove(MetricRegistry.name(poolName, METRIC_CATEGORY, METRIC_NAME_MIN_CONNECTIONS)); }
@Override public void notifyOfRemovedMetric(Metric metric, String metricName, MetricGroup group) { synchronized (this) { String fullName; if (metric instanceof Counter) { fullName = counters.remove(metric); } else if (metric instanceof Gauge) { fullName = gauges.remove(metric); } else if (metric instanceof Histogram) { fullName = histograms.remove(metric); } else if (metric instanceof Meter) { fullName = meters.remove(metric); } else { fullName = null; } if (fullName != null) { registry.remove(fullName); } } }
public boolean remove(String name) { return getRegistry().remove(name); } }
/** * Resets the metric registry and removes all the metrics. */ public static void clearAllMetrics() { for (String name : METRIC_REGISTRY.getNames()) { METRIC_REGISTRY.remove(name); } }
/** * Note: For counters, histograms, meters and timers, use get or create methods on {@link #getRegistry the * registry} (e.g. {@link MetricRegistry#counter}). For {@link com.codahale.metrics.Gauge gauges} or custom * metric implementations use this method. The registry does not allow registering multiple metrics with * the same name, which is a problem when multiple drillbits are started in the same JVM (e.g. unit tests). * * @param name metric name * @param metric metric instance * @param <T> metric type */ public synchronized static <T extends Metric> void register(String name, T metric) { boolean removed = RegistryHolder.REGISTRY.remove(name); if (removed) { logger.warn("Removing old metric since name matched newly registered metric. Metric name: {}", name); } RegistryHolder.REGISTRY.register(name, metric); }
@Override public void removeGauge(String name) { try { gaugesLock.lock(); gauges.remove(name); // Metrics throws an Exception if we don't do this when the key already exists if (metricRegistry.getGauges().containsKey(name)) { metricRegistry.remove(name); } } finally { gaugesLock.unlock(); } }
public boolean remove(String name) { return getRegistry().remove(name); } }
@Override public void close() throws Exception { if (reporters != null) { for (Closeable reporter : reporters) { reporter.close(); } } for (Map.Entry<String, Metric> metric : metricRegistry.getMetrics().entrySet()) { metricRegistry.remove(metric.getKey()); } timers.invalidateAll(); counters.invalidateAll(); meters.invalidateAll(); }
/** * Removes all metrics which match the given filter. * * @param filter a filter */ public void removeMatching(MetricFilter filter) { for (Map.Entry<String, Metric> entry : metrics.entrySet()) { if (filter.matches(entry.getKey(), entry.getValue())) { remove(entry.getKey()); } } }
private void addGaugeInternal(String name, Gauge gauge) { try { gaugesLock.lock(); gauges.put(name, gauge); // Metrics throws an Exception if we don't do this when the key already exists if (metricRegistry.getGauges().containsKey(name)) { LOGGER.warn("A Gauge with name [" + name + "] already exists. " + " The old gauge will be overwritten, but this is not recommended"); metricRegistry.remove(name); } metricRegistry.register(name, gauge); } finally { gaugesLock.unlock(); } }
private void addGaugeInternal(String name, Gauge gauge) { try { gaugesLock.lock(); gauges.put(name, gauge); // Metrics throws an Exception if we don't do this when the key already exists if (metricRegistry.getGauges().containsKey(name)) { LOGGER.warn("A Gauge with name [" + name + "] already exists. " + " The old gauge will be overwritten, but this is not recommended"); metricRegistry.remove(name); } metricRegistry.register(name, gauge); } finally { gaugesLock.unlock(); } }
/** * Removes the metric with the given name. * * @param name the name of the metric * @return whether or not the metric was removed */ public boolean remove(MetricName name) { final Metric metric = metrics.remove(name); if (metric != null) { // We have to unregister the Metric with the legacy Dropwizard Metric registry as // well to support existing reports and listeners metricRegistry.remove(name.toGraphiteName()); return true; } return false; }
@Override public void close() throws Exception { if (reporters != null) { for (Closeable reporter : reporters) { reporter.close(); } } for (Map.Entry<String, Metric> metric : metricRegistry.getMetrics().entrySet()) { metricRegistry.remove(metric.getKey()); } try { timersLock.lock(); timers.invalidateAll(); } finally { timersLock.unlock(); } try { countersLock.lock(); counters.invalidateAll(); } finally { countersLock.unlock(); } try { metersLock.lock(); meters.invalidateAll(); } finally { metersLock.unlock(); } }
private void cleanupMetrics() { if (localRegistry != null && localRegistry.getMetrics() != null) for (String metricName : localRegistry.getMetrics().keySet()) metricRegistry.remove(getUniqueReadableId() + "." + metricName); if (this.transportMetrics != null && this.transportMetrics.getMetrics() != null) for (String metricName : this.transportMetrics.getMetrics().keySet()) metricRegistry.remove(getUniqueReadableId() + "." + metricName); }
@Test public void simpleCreate() throws Exception { final EntityManager em = app.getEntityManager(); final long stopTime = System.currentTimeMillis() + RUNTIME; final Map<String, Object> addToCollectionEntity = new HashMap<>(); addToCollectionEntity.put( "key1", 1000 ); addToCollectionEntity.put( "key2", 2000 ); addToCollectionEntity.put( "key3", "Some value" ); int i = 0; final String meterName = this.getClass().getSimpleName() + ".simpleCreate"; final Meter meter = registry.meter( meterName ); while ( System.currentTimeMillis() < stopTime ) { addToCollectionEntity.put( "key", i ); final Entity created = em.create( "testType", addToCollectionEntity ); meter.mark(); i++; } registry.remove( meterName ); }
registry.remove( meterName ); logger.info("Finished simpleReadUUID()");
registry.remove( meterName ); logger.info("Finished simpleReadEntityRef()");
registry.remove( meterName );
MetricsSystem.METRIC_REGISTRY.remove(filesPinnedProperty);