com.codahale.metrics.MetricSet Java Examples
The following examples show how to use
com.codahale.metrics.MetricSet.
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: IrisMetrics.java From arcusplatform with Apache License 2.0 | 6 votes |
private static final void registerIfPossible(String set, String className) { try { Class<?> clazz = Class.forName(className); Constructor<?> constructor = clazz.getConstructor(); Object instance = constructor.newInstance(); registerAll(set, (MetricSet)instance); logger.debug("successfully registered metric set {}", set); } catch (Throwable th) { if (logger.isTraceEnabled()) { logger.debug("unable to register metric set {}: {}", set, th.getMessage(), th); } else { logger.debug("unable to register metric set {}: {}", set, th.getMessage()); } } }
Example #2
Source File: MetricsExtension.java From metrics-cdi with Apache License 2.0 | 6 votes |
private void configuration(@Observes AfterDeploymentValidation adv, BeanManager manager) { // Fire configuration event manager.fireEvent(configuration); configuration.unmodifiable(); // Produce and register custom metrics MetricRegistry registry = getReference(manager, MetricRegistry.class); MetricName metricName = getReference(manager, MetricName.class); for (Map.Entry<Bean<?>, AnnotatedMember<?>> bean : metrics.entrySet()) { // TODO: add MetricSet metrics into the metric registry if (bean.getKey().getTypes().contains(MetricSet.class) // skip non @Default beans || !bean.getKey().getQualifiers().contains(DEFAULT) // skip producer methods with injection point || hasInjectionPoints(bean.getValue())) continue; registry.register(metricName.of(bean.getValue()), (Metric) getReference(manager, bean.getValue().getBaseType(), bean.getKey())); } // Let's clear the collected metric producers metrics.clear(); }
Example #3
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 #4
Source File: RegisterJVMMetricsBuilder.java From kite with Apache License 2.0 | 5 votes |
private void registerAll(String prefix, MetricSet metrics, MetricRegistry registry) { for (Map.Entry<String, Metric> entry : metrics.getMetrics().entrySet()) { String name = MetricRegistry.name(prefix, entry.getKey()); if (entry.getValue() instanceof MetricSet) { registerAll(name, (MetricSet) entry.getValue(), registry); } else { register(name, entry.getValue(), registry); } } }
Example #5
Source File: CodahaleMetrics.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
private void registerAll(String prefix, MetricSet metricSet) { for (Map.Entry<String, Metric> entry : metricSet.getMetrics().entrySet()) { if (entry.getValue() instanceof MetricSet) { registerAll(prefix + "." + entry.getKey(), (MetricSet) entry.getValue()); } else { metricRegistry.register(prefix + "." + entry.getKey(), entry.getValue()); } } }
Example #6
Source File: SentryMetrics.java From incubator-sentry with Apache License 2.0 | 5 votes |
private void registerMetricSet(String prefix, MetricSet metricSet, MetricRegistry registry) { for (Map.Entry<String, Metric> entry : metricSet.getMetrics().entrySet()) { if (entry.getValue() instanceof MetricSet) { registerMetricSet(prefix + "." + entry.getKey(), (MetricSet) entry.getValue(), registry); } else { registry.register(prefix + "." + entry.getKey(), entry.getValue()); } } }
Example #7
Source File: MetricsInitializer.java From pippo with Apache License 2.0 | 5 votes |
private void registerAll(String prefix, MetricSet metrics) throws IllegalArgumentException { for (Map.Entry<String, Metric> entry : metrics.getMetrics().entrySet()) { if (entry.getValue() instanceof MetricSet) { registerAll(MetricRegistry.name(prefix, entry.getKey()), (MetricSet) entry.getValue()); } else { metricRegistry.register(MetricRegistry.name(prefix, entry.getKey()), entry.getValue()); } } }
Example #8
Source File: JMXReportingService.java From incubator-gobblin with Apache License 2.0 | 5 votes |
private void registerJvmMetrics() { registerMetricSetWithPrefix("jvm.gc", new GarbageCollectorMetricSet()); registerMetricSetWithPrefix("jvm.memory", new MemoryUsageGaugeSet()); registerMetricSetWithPrefix("jvm.threads", new ThreadStatesGaugeSet()); this.metricRegistry.register("jvm.fileDescriptorRatio", new FileDescriptorRatioGauge()); for (Map.Entry<String, MetricSet> metricSet : this.additionalMetricSets.entrySet()) { registerMetricSetWithPrefix(metricSet.getKey(), metricSet.getValue()); } }
Example #9
Source File: CodahaleMetrics.java From kylin with Apache License 2.0 | 5 votes |
private void registerAll(String prefix, MetricSet metricSet) { for (Map.Entry<String, Metric> entry : metricSet.getMetrics().entrySet()) { if (entry.getValue() instanceof MetricSet) { registerAll(prefix + "." + entry.getKey(), (MetricSet) entry.getValue()); } else { metricRegistry.register(prefix + "." + entry.getKey(), entry.getValue()); } } }
Example #10
Source File: CodahaleMetricsCollector.java From riposte with Apache License 2.0 | 5 votes |
@SuppressWarnings("UnusedReturnValue") public @NotNull CodahaleMetricsCollector registerAll(String prefix, @NotNull MetricSet metricSet) { for (Map.Entry<String, Metric> entry : metricSet.getMetrics().entrySet()) { if (entry.getValue() instanceof MetricSet) { registerAll(prefix + "." + entry.getKey(), (MetricSet) entry.getValue()); } else { registerNamedMetric(prefix + "." + entry.getKey(), entry.getValue()); } } return this; }
Example #11
Source File: MetricSystem.java From Microservices-Deployment-Cookbook with MIT License | 5 votes |
@PostConstruct public void init() { // ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(metricRegistry) // .convertRatesTo(TimeUnit.SECONDS) // .convertDurationsTo(TimeUnit.MILLISECONDS) // .build(); // // consoleReporter.start(10, TimeUnit.SECONDS); // Graphite graphite = new Graphite(new InetSocketAddress("192.168.99.100", 2003)); // GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry) // .prefixedWith("com.packt.microservices.geolocation") // .convertRatesTo(TimeUnit.SECONDS) // .convertDurationsTo(TimeUnit.MILLISECONDS) // .filter(MetricFilter.ALL) // .build(graphite); // graphiteReporter.start(60, TimeUnit.SECONDS); geolocationWriteRequestCount = metricRegistry.counter("geolocationWriteRequestCount"); metricRegistry.register("geolocationLastWriteTime", new Gauge<Long>() { @Override public Long getValue() { return geolocationLastWriteTime; } }); metricRegistry.registerAll(new MetricSet() { @Override public Map<String, Metric> getMetrics() { Map<String, Metric> metrics = new HashMap<>(); metrics.put("geolocationMemoryUsage", new MemoryUsageGaugeSet()); metrics.put("geolocationClassLoading", new ClassLoadingGaugeSet()); metrics.put("geolocationGarbageCollector", new GarbageCollectorMetricSet()); return metrics; } }); }
Example #12
Source File: Metrics.java From dremio-oss with Apache License 2.0 | 5 votes |
private static MetricSet scoped(final String name, final MetricSet metricSet) { return new MetricSet() { @Override public Map<String, Metric> getMetrics() { ImmutableMap.Builder<String, Metric> scopedMetrics = ImmutableMap.builder(); for(Map.Entry<String, Metric> entry: metricSet.getMetrics().entrySet()) { scopedMetrics.put(MetricRegistry.name(name, entry.getKey()), entry.getValue()); } return scopedMetrics.build(); } }; }
Example #13
Source File: IrisMetrics.java From arcusplatform with Apache License 2.0 | 5 votes |
private static void registerAll(String prefix, MetricSet metricSet) { for (Map.Entry<String, Metric> entry : metricSet.getMetrics().entrySet()) { if (entry.getValue() instanceof MetricSet) { registerAll(prefix + "." + entry.getKey(), (MetricSet) entry.getValue()); } else { if (!(registry.getNames().contains(prefix + "." + entry.getKey()))) { registry.register(prefix + "." + entry.getKey(), entry.getValue()); } } } }
Example #14
Source File: IrisMetrics.java From arcusplatform with Apache License 2.0 | 5 votes |
public static void unregisterAll(MetricSet set) { if (set != null) { for (String name : set.getMetrics().keySet()) { IrisMetrics.registry().remove(name); } } }
Example #15
Source File: RatisMetricRegistryImpl.java From incubator-ratis with Apache License 2.0 | 5 votes |
@Override public void registerAll(String prefix, MetricSet metricSet) { for (Map.Entry<String, Metric> entry : metricSet.getMetrics().entrySet()) { if (entry.getValue() instanceof MetricSet) { registerAll(prefix + "." + entry.getKey(), (MetricSet) entry.getValue()); } else { register(prefix + "." + entry.getKey(), entry.getValue()); } } }
Example #16
Source File: Metrics.java From dremio-oss with Apache License 2.0 | 5 votes |
/** * Create a new reporter that reports the top slow operations over time. * @param name The name of the metric * @param count The number of items to keep (eg 10 for top 10) * @param latencyThreshold The latency below which observations should be ignored. * @param reset The desired reset behavior. * @return The reporter to use. */ public static synchronized TopMonitor newTopReporter(String name, int count, Duration latencyThreshold, ResetType reset) { TopBuilder builder = Top.builder(count).withLatencyThreshold(latencyThreshold); switch(reset) { case NEVER: builder.neverResetPositions(); break; case ON_SNAPSHOT: builder.resetAllPositionsOnSnapshot(); break; case PERIODIC_15M: case PERIODIC_1D: case PERIODIC_7D: builder.resetAllPositionsPeriodically(reset.getDuration()); break; case PERIODIC_DECAY: builder.resetPositionsPeriodicallyByChunks(reset.getDuration(), DECAY_CHUNKS); break; default: throw new UnsupportedOperationException("Unknown type: " + reset); } Top top = builder.build(); MetricSet metricSet = new TopMetricSet(name, top, TimeUnit.MILLISECONDS, 2); RegistryHolder.REGISTRY.registerAll(metricSet); return (latency, desc, tags) -> top.update(System.currentTimeMillis(), latency, TimeUnit.MILLISECONDS, () -> desc.get()); }
Example #17
Source File: HttpMonitorTransport.java From graylog2-plugin-input-httpmonitor with MIT License | 4 votes |
@Override public MetricSet getMetricSet() { return null; }
Example #18
Source File: ModbusTcpMaster.java From modbus with Apache License 2.0 | 4 votes |
public MetricSet getMetricSet() { return () -> metrics; }
Example #19
Source File: TaskExecutor.java From incubator-gobblin with Apache License 2.0 | 4 votes |
public MetricSet getTaskExecutorQueueMetricSet() { return this.metricSet; }
Example #20
Source File: JMXReportingService.java From incubator-gobblin with Apache License 2.0 | 4 votes |
public JMXReportingService(Map<String, MetricSet> additionalMetricSets) { this.additionalMetricSets = additionalMetricSets; }
Example #21
Source File: TaggedMetricRegistry.java From SpinalTap with Apache License 2.0 | 4 votes |
public void registerAll(MetricSet metrics) { registry.registerAll(metrics); }
Example #22
Source File: JMXReportingService.java From incubator-gobblin with Apache License 2.0 | 4 votes |
private void registerMetricSetWithPrefix(String prefix, MetricSet metricSet) { for (Map.Entry<String, Metric> entry : metricSet.getMetrics().entrySet()) { this.metricRegistry.register(MetricRegistry.name(prefix, entry.getKey()), entry.getValue()); } }
Example #23
Source File: InnerMetricContext.java From incubator-gobblin with Apache License 2.0 | 4 votes |
@Override public void registerAll(MetricSet metrics) throws IllegalArgumentException { throw new UnsupportedOperationException(); }
Example #24
Source File: KinesisTransport.java From graylog-plugin-aws with Apache License 2.0 | 4 votes |
@Override public MetricSet getMetricSet() { return localRegistry; }
Example #25
Source File: CloudTrailTransport.java From graylog-plugin-aws with Apache License 2.0 | 4 votes |
@Override public MetricSet getMetricSet() { return localRegistry; }
Example #26
Source File: DetectorMapperCache.java From adaptive-alerting with Apache License 2.0 | 4 votes |
private MetricSet metricsFor(String cacheName, final Cache cache) { HashMap<String, Metric> metrics = new HashMap<>(); metrics.put(name(cacheName, "requestCount"), (Gauge<Long>) () -> cache.stats().requestCount()); metrics.put(name(cacheName, "hitCount"), (Gauge<Long>) () -> cache.stats().hitCount()); metrics.put(name(cacheName, "hitRate"), (Gauge<Double>) () -> cache.stats().hitRate()); metrics.put(name(cacheName, "missCount"), (Gauge<Long>) () -> cache.stats().missCount()); metrics.put(name(cacheName, "missRate"), (Gauge<Double>) () -> cache.stats().missRate()); metrics.put(name(cacheName, "evictionCount"), (Gauge<Long>) () -> cache.stats().evictionCount()); metrics.put(name(cacheName, "exceptionCount"), (Gauge<Long>) () -> cache.stats().loadExceptionCount()); metrics.put(name(cacheName, "exceptionRate"), (Gauge<Double>) () -> cache.stats().loadExceptionRate()); metrics.put(name(cacheName, "totalLoadTime"), (Gauge<Long>) () -> cache.stats().totalLoadTime()); metrics.put(name(cacheName, "size"), (Gauge<Long>) cache::size); return () -> metrics; }
Example #27
Source File: IrisMetrics.java From arcusplatform with Apache License 2.0 | 4 votes |
public static void registerAll(MetricSet set) { if (set != null) { IrisMetrics.registry().registerAll(set); } }
Example #28
Source File: RatisMetricRegistry.java From incubator-ratis with Apache License 2.0 | votes |
void registerAll(String prefix, MetricSet metricSet);