use of com.codahale.metrics.Histogram in project spring-boot by spring-projects.
the class DropwizardMetricServices method submitHistogram.
private void submitHistogram(String name, double value) {
long longValue = (long) value;
Histogram metric = register(name, new HistogramMetricRegistrar());
metric.update(longValue);
}
use of com.codahale.metrics.Histogram in project jackrabbit-oak by apache.
the class CompositeStatsTest method histogram.
@Test
public void histogram() throws Exception {
Histogram histo = registry.histogram("test");
CompositeStats histoStats = new CompositeStats(new AtomicLong(), histo);
histoStats.update(100);
assertEquals(1, histo.getCount());
assertEquals(100, histo.getSnapshot().getMax());
assertFalse(histoStats.isMeter());
assertFalse(histoStats.isTimer());
assertFalse(histoStats.isCounter());
assertTrue(histoStats.isHistogram());
assertNotNull(histoStats.getHistogram());
}
use of com.codahale.metrics.Histogram in project jackrabbit-oak by apache.
the class MetricImplTest method histogram.
@Test
public void histogram() throws Exception {
Histogram histo = registry.histogram("test");
HistogramImpl histoStats = new HistogramImpl(histo);
histoStats.update(100);
assertEquals(1, histo.getCount());
assertEquals(100, histo.getSnapshot().getMax());
}
use of com.codahale.metrics.Histogram in project lucene-solr by apache.
the class MetricUtils method convertMetric.
/**
* Convert a single instance of metric into a map or flattened object.
* @param n metric name
* @param metric metric instance
* @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
*/
static void convertMetric(String n, Metric metric, PropertyFilter propertyFilter, boolean skipHistograms, boolean skipAggregateValues, boolean compact, boolean simple, BiConsumer<String, Object> consumer) {
if (metric instanceof Counter) {
Counter counter = (Counter) metric;
convertCounter(n, counter, propertyFilter, compact, consumer);
} else if (metric instanceof Gauge) {
Gauge gauge = (Gauge) metric;
try {
convertGauge(n, gauge, propertyFilter, simple, compact, consumer);
} catch (InternalError ie) {
if (n.startsWith("memory.") && ie.getMessage().contains("Memory Pool not found")) {
LOG.warn("Error converting gauge '" + n + "', possible JDK bug: SOLR-10362", ie);
consumer.accept(n, null);
} else {
throw ie;
}
}
} else if (metric instanceof Meter) {
Meter meter = (Meter) metric;
convertMeter(n, meter, propertyFilter, simple, consumer);
} else if (metric instanceof Timer) {
Timer timer = (Timer) metric;
convertTimer(n, timer, propertyFilter, skipHistograms, simple, consumer);
} else if (metric instanceof Histogram) {
if (!skipHistograms) {
Histogram histogram = (Histogram) metric;
convertHistogram(n, histogram, propertyFilter, simple, consumer);
}
} else if (metric instanceof AggregateMetric) {
convertAggregateMetric(n, (AggregateMetric) metric, propertyFilter, skipAggregateValues, simple, consumer);
}
}
use of com.codahale.metrics.Histogram in project ddf by codice.
the class SourceMetricsImpl method updateMetric.
public void updateMetric(String sourceId, String name, int incrementAmount) {
LOGGER.debug("sourceId = {}, name = {}", sourceId, name);
if (StringUtils.isBlank(sourceId) || StringUtils.isBlank(name)) {
return;
}
String mapKey = sourceId + "." + name;
SourceMetric sourceMetric = metrics.get(mapKey);
if (sourceMetric == null) {
LOGGER.debug("sourceMetric is null for {} - creating metric now", mapKey);
// Loop through list of all sources until find the sourceId whose metric is being
// updated
boolean created = createMetric(catalogProviders, sourceId);
if (!created) {
createMetric(federatedSources, sourceId);
}
sourceMetric = metrics.get(mapKey);
}
// If this metric already exists, then just update its MBean
if (sourceMetric != null) {
LOGGER.debug("CASE 1: Metric already exists for {}", mapKey);
if (sourceMetric.isHistogram()) {
Histogram metric = (Histogram) sourceMetric.getMetric();
LOGGER.debug("Updating histogram metric {} by amount of {}", name, incrementAmount);
metric.update(incrementAmount);
} else {
Meter metric = (Meter) sourceMetric.getMetric();
LOGGER.debug("Updating metric {} by amount of {}", name, incrementAmount);
metric.mark(incrementAmount);
}
return;
}
}
Aggregations