use of com.codahale.metrics.Counting in project jackrabbit-oak by apache.
the class BenchmarkRunner method reportMetrics.
private static void reportMetrics(StatisticsProvider statsProvider) {
if (statsProvider instanceof MetricStatisticsProvider) {
MetricRegistry metricRegistry = ((MetricStatisticsProvider) statsProvider).getRegistry();
ConsoleReporter.forRegistry(metricRegistry).outputTo(System.out).filter(new MetricFilter() {
@Override
public boolean matches(String name, Metric metric) {
if (metric instanceof Counting) {
// Only report non zero metrics
return ((Counting) metric).getCount() > 0;
}
return true;
}
}).build().report();
}
}
use of com.codahale.metrics.Counting in project jackrabbit-oak by apache.
the class NodeStoreFixtureProvider method reportMetrics.
private static void reportMetrics(MetricStatisticsProvider statsProvider) {
MetricRegistry metricRegistry = statsProvider.getRegistry();
ConsoleReporter.forRegistry(metricRegistry).outputTo(System.out).filter((name, metric) -> {
if (metric instanceof Counting) {
// Only report non zero metrics
return ((Counting) metric).getCount() > 0;
}
return true;
}).build().report();
}
use of com.codahale.metrics.Counting in project cassandra by apache.
the class TableMetricTables method buildMetadata.
/**
* Identify the type of Metric it is (gauge, counter etc) abd create the TableMetadata. The column name
* and type for a counter/gauge is formatted differently based on the units (bytes/time) so allowed to
* be set.
*/
private static TableMetadata buildMetadata(String keyspace, String table, Function<TableMetrics, ? extends Metric> func, String colName, AbstractType colType, String suffix) {
TableMetadata.Builder metadata = TableMetadata.builder(keyspace, table).kind(TableMetadata.Kind.VIRTUAL).addPartitionKeyColumn(KEYSPACE_NAME, UTF8Type.instance).addPartitionKeyColumn(TABLE_NAME, UTF8Type.instance).partitioner(PARTITIONER);
// get a table from system keyspace and get metric from it for determining type of metric
Keyspace system = Keyspace.system().iterator().next();
Metric test = func.apply(system.getColumnFamilyStores().iterator().next().metric);
if (test instanceof Counting) {
metadata.addRegularColumn(colName, colType);
// if it has a Histogram include some information about distribution
if (test instanceof Sampling) {
metadata.addRegularColumn(P50 + suffix, DoubleType.instance).addRegularColumn(P99 + suffix, DoubleType.instance).addRegularColumn(MAX + suffix, DoubleType.instance);
}
if (test instanceof Metered) {
metadata.addRegularColumn(RATE, DoubleType.instance);
}
} else if (test instanceof Gauge) {
metadata.addRegularColumn(colName, colType);
}
return metadata.build();
}
use of com.codahale.metrics.Counting in project graylog2-server by Graylog2.
the class ThroughputCalculator method doRun.
@Override
public void doRun() {
final SortedMap<String, ? extends Counting> counters = metricRegistry.getCounters(filterSingleMetric(GlobalMetricNames.OUTPUT_THROUGHPUT));
// rinse and repeat for input throughput
final SortedMap<String, ? extends Counting> inputCounters = metricRegistry.getCounters(filterSingleMetric(GlobalMetricNames.INPUT_THROUGHPUT));
// StreamMetrics isn't accessible here, so we need to use a metrics filter instead.
final SortedMap<String, ? extends Counting> streamMeters = metricRegistry.getMeters(streamMetricFilter);
final Iterable<Map.Entry<String, ? extends Counting>> entries = Iterables.concat(counters.entrySet(), inputCounters.entrySet(), streamMeters.entrySet());
// calculate rates
for (Map.Entry<String, ? extends Counting> countingEntry : entries) {
final Counting value = countingEntry.getValue();
final String metricName = countingEntry.getKey();
CounterSample counterSample = sampledCounters.get(metricName);
if (counterSample == null) {
counterSample = new CounterSample();
sampledCounters.put(metricName, counterSample);
}
counterSample.updateAverage(value.getCount());
final String rateName = name(metricName, GlobalMetricNames.RATE_SUFFIX);
if (!metricRegistry.getMetrics().containsKey(rateName)) {
try {
log.debug("Registering derived, per-second metric {}", rateName);
metricRegistry.register(rateName, new Gauge<Double>() {
@Override
public Double getValue() {
final CounterSample sample = sampledCounters.get(metricName);
return sample == null ? 0d : sample.getCurrentAverage();
}
});
} catch (IllegalArgumentException e) {
log.warn("Could not register gauge {} despite checking before that it didn't exist. This should not happen.", rateName);
}
}
}
}
use of com.codahale.metrics.Counting in project stdlib by petergeneric.
the class MetricsRestServiceImpl method getIndex.
@Override
public String getIndex() {
TemplateCall call = templater.template(PREFIX + "index.html");
call.set("gauges", registry.getGauges().entrySet());
call.set("counters", this.<Counting>combine(registry.getCounters(), registry.getMeters(), registry.getTimers(), registry.getHistograms()).entrySet());
call.set("meters", this.<Metered>combine(registry.getMeters(), registry.getTimers()).entrySet());
call.set("histograms", this.<Sampling>combine(registry.getHistograms(), registry.getTimers()).entrySet());
return call.process();
}
Aggregations