use of org.apache.hadoop.metrics2.annotation.Metrics in project hadoop by apache.
the class SharedCacheUploaderMetrics method create.
static SharedCacheUploaderMetrics create() {
MetricsSystem ms = DefaultMetricsSystem.instance();
SharedCacheUploaderMetrics metrics = new SharedCacheUploaderMetrics();
ms.register("SharedCacheUploaderRequests", null, metrics);
return metrics;
}
use of org.apache.hadoop.metrics2.annotation.Metrics in project hbase by apache.
the class Interns method tag.
/**
* Get a metrics tag
*
* @param info of the tag
* @param value of the tag
* @return an interned metrics tag
*/
public static MetricsTag tag(MetricsInfo info, String value) {
Map<String, MetricsTag> map = tagCache.getUnchecked(info);
MetricsTag tag = map.get(value);
if (tag == null) {
tag = new MetricsTag(info, value);
map.put(value, tag);
}
return tag;
}
use of org.apache.hadoop.metrics2.annotation.Metrics in project hbase by apache.
the class HBaseMetrics2HadoopMetricsAdapter method snapshotAllMetrics.
/**
* Iterates over the MetricRegistry and adds them to the {@code collector}.
*
* @param collector A metrics collector
*/
public void snapshotAllMetrics(MetricRegistry metricRegistry, MetricsCollector collector) {
MetricRegistryInfo info = metricRegistry.getMetricRegistryInfo();
MetricsRecordBuilder builder = collector.addRecord(Interns.info(info.getMetricsName(), info.getMetricsDescription()));
builder.setContext(info.getMetricsContext());
snapshotAllMetrics(metricRegistry, builder);
}
use of org.apache.hadoop.metrics2.annotation.Metrics in project hbase by apache.
the class HBaseMetrics2HadoopMetricsAdapter method snapshotAllMetrics.
/**
* Iterates over the MetricRegistry and adds them to the {@code builder}.
*
* @param builder A record builder
*/
public void snapshotAllMetrics(MetricRegistry metricRegistry, MetricsRecordBuilder builder) {
Map<String, Metric> metrics = metricRegistry.getMetrics();
for (Map.Entry<String, Metric> e : metrics.entrySet()) {
// Always capitalize the name
String name = StringUtils.capitalize(e.getKey());
Metric metric = e.getValue();
if (metric instanceof Gauge) {
addGauge(name, (Gauge<?>) metric, builder);
} else if (metric instanceof Counter) {
addCounter(name, (Counter) metric, builder);
} else if (metric instanceof Histogram) {
addHistogram(name, (Histogram) metric, builder);
} else if (metric instanceof Meter) {
addMeter(name, (Meter) metric, builder);
} else if (metric instanceof Timer) {
addTimer(name, (Timer) metric, builder);
} else {
LOG.info("Ignoring unknown Metric class " + metric.getClass().getName());
}
}
}
use of org.apache.hadoop.metrics2.annotation.Metrics in project hbase by apache.
the class MetricsTableAggregateSourceImpl method getMetrics.
/**
* Yes this is a get function that doesn't return anything. Thanks Hadoop for breaking all
* expectations of java programmers. Instead of returning anything Hadoop metrics expects
* getMetrics to push the metrics into the collector.
*
* @param collector the collector
* @param all get all the metrics regardless of when they last changed.
*/
@Override
public void getMetrics(MetricsCollector collector, boolean all) {
MetricsRecordBuilder mrb = collector.addRecord(metricsName);
if (tableSources != null) {
for (MetricsTableSource tableMetricSource : tableSources.values()) {
if (tableMetricSource instanceof MetricsTableSourceImpl) {
((MetricsTableSourceImpl) tableMetricSource).snapshot(mrb, all);
}
}
mrb.addGauge(Interns.info(NUM_TABLES, NUMBER_OF_TABLES_DESC), tableSources.size());
metricsRegistry.snapshot(mrb, all);
}
}
Aggregations