Java Code Examples for com.codahale.metrics.MetricRegistry#remove()
The following examples show how to use
com.codahale.metrics.MetricRegistry#remove() .
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: SolrMetricManager.java From lucene-solr with Apache License 2.0 | 6 votes |
/** * Register all metrics in the provided {@link MetricSet}, optionally skipping those that * already exist. * * @param registry registry name * @param metrics metric set to register * @param strategy the conflict resolution strategy to use if the named metric already exists. * @param metricPath (optional) additional top-most metric name path elements * @throws Exception if a metric with this name already exists. */ public void registerAll(String registry, MetricSet metrics, ResolutionStrategy strategy, String... metricPath) throws Exception { MetricRegistry metricRegistry = registry(registry); synchronized (metricRegistry) { Map<String, Metric> existingMetrics = metricRegistry.getMetrics(); for (Map.Entry<String, Metric> entry : metrics.getMetrics().entrySet()) { String fullName = mkName(entry.getKey(), metricPath); if (existingMetrics.containsKey(fullName)) { if (strategy == ResolutionStrategy.REPLACE) { metricRegistry.remove(fullName); } else if (strategy == ResolutionStrategy.IGNORE) { continue; } // strategy == ERROR will fail when we try to register later } metricRegistry.register(fullName, entry.getValue()); } } }
Example 2
Source File: SolrMetricManager.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Register an instance of {@link Metric}. * * @param registry registry name * @param metric metric instance * @param force if true then an already existing metric with the same name will be replaced. * When false and a metric with the same name already exists an exception * will be thrown. * @param metricName metric name, either final name or a fully-qualified name * using dotted notation * @param metricPath (optional) additional top-most metric name path elements */ public void registerMetric(SolrMetricsContext context, String registry, Metric metric, boolean force, String metricName, String... metricPath) { MetricRegistry metricRegistry = registry(registry); String fullName = mkName(metricName, metricPath); if (context != null) { context.registerMetricName(fullName); } synchronized (metricRegistry) { // prevent race; register() throws if metric is already present if (force) { // must remove any existing one if present metricRegistry.remove(fullName); } metricRegistry.register(fullName, metric); } }
Example 3
Source File: SingleMetricAbstractOplet.java From quarks with Apache License 2.0 | 5 votes |
@Override public final void close() throws Exception { MetricRegistry registry = getOpletContext().getService(MetricRegistry.class); if (registry != null) { registry.remove(getMetricName()); } }
Example 4
Source File: MetricsConfigurator.java From datacollector with Apache License 2.0 | 5 votes |
/** * Remove metric object (regardless of it's type) */ private static boolean remove(final MetricRegistry metrics, final String name, String pipelineName, String pipelineRev) { final String jmxNamePrefix = jmxPipelinePrefix(pipelineName, pipelineRev); final MetricRegistry metricRegistry = sdcMetrics; if (metricRegistry != null) { AccessController.doPrivileged(new PrivilegedAction<Void>() { @Override public Void run() { metricRegistry.remove(jmxNamePrefix + name); return null; } }); } return metrics.remove(name); }
Example 5
Source File: MetricMetadataImpl.java From signalfx-java with Apache License 2.0 | 5 votes |
@Override public <M extends Metric> boolean removeMetric(M metric, MetricRegistry metricRegistry) { Metadata metadata = metaDataCollection.remove(metric); if (metadata == null) { return false; } metricRegistry.remove(metadata.getCodahaleName()); return true; }
Example 6
Source File: LastActivityMetricsCollector.java From fahrschein with Apache License 2.0 | 4 votes |
private void createOrReplaceGauge(final MetricRegistry metricRegistry, final String gaugeName, final LongSupplier gaugeValueSupplier) { metricRegistry.remove(gaugeName); metricRegistry.register(gaugeName, (Gauge<Integer>) () -> (int) gaugeValueSupplier.getAsLong()); }
Example 7
Source File: MetricMediator.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
public void remove(final BeanEntry<Named, Metric> entry, final MetricRegistry registry) throws Exception { log.debug("Un-registering: {}", entry); registry.remove(entry.getKey().value()); }