use of org.apache.hadoop.metrics2.MetricsCollector in project ozone by apache.
the class ReconTaskStatusMetrics method getMetrics.
public void getMetrics(MetricsCollector collector, boolean all) {
List<ReconTaskStatus> rows = reconTaskStatusDao.findAll();
rows.forEach((rts) -> {
MetricsRecordBuilder builder = collector.addRecord(SOURCE_NAME);
builder.add(new MetricsTag(Interns.info("type", "Recon Task type"), rts.getTaskName()));
builder.addGauge(RECORD_INFO_LAST_UPDATED_TS, rts.getLastUpdatedTimestamp());
builder.addCounter(RECORD_INFO_LAST_UPDATED_SEQ, rts.getLastUpdatedSeqNumber());
builder.endRecord();
});
}
use of org.apache.hadoop.metrics2.MetricsCollector in project ozone by apache.
the class ProtocolMessageMetrics method getMetrics.
@Override
public void getMetrics(MetricsCollector collector, boolean all) {
counters.forEach((key, value) -> {
MetricsRecordBuilder builder = collector.addRecord(name);
builder.add(new MetricsTag(Interns.info("type", "Message type"), key.toString()));
builder.addCounter(new MetricName("counter", "Number of distinct calls"), value.longValue());
builder.addCounter(new MetricName("time", "Sum of the duration of the calls"), elapsedTimes.get(key).longValue());
builder.endRecord();
});
}
use of org.apache.hadoop.metrics2.MetricsCollector in project ozone by apache.
the class SCMNodeMetrics method getMetrics.
/**
* Get aggregated counter and gauge metrics.
*/
@Override
@SuppressWarnings("SuspiciousMethodCalls")
public void getMetrics(MetricsCollector collector, boolean all) {
Map<String, Map<String, Integer>> nodeCount = managerMXBean.getNodeCount();
Map<String, Long> nodeInfo = managerMXBean.getNodeInfo();
/**
* Loop over the Node map and create a metric for the cross product of all
* Operational and health states, ie:
* InServiceHealthy
* InServiceStale
* ...
* EnteringMaintenanceHealthy
* ...
*/
MetricsRecordBuilder metrics = collector.addRecord(registry.info());
for (Map.Entry<String, Map<String, Integer>> e : nodeCount.entrySet()) {
for (Map.Entry<String, Integer> h : e.getValue().entrySet()) {
metrics.addGauge(Interns.info(StringUtils.camelize(e.getKey() + "_" + h.getKey() + "_nodes"), "Number of " + e.getKey() + " " + h.getKey() + " datanodes"), h.getValue());
}
}
for (Map.Entry<String, Long> e : nodeInfo.entrySet()) {
metrics.addGauge(Interns.info(e.getKey(), diskMetricDescription(e.getKey())), e.getValue());
}
registry.snapshot(metrics, all);
}
use of org.apache.hadoop.metrics2.MetricsCollector in project hbase-filesystem by apache.
the class MetricsOSSSourceImpl 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 metricsCollector Collector to accept metrics
* @param all push all or only changed?
*/
@Override
public void getMetrics(MetricsCollector metricsCollector, boolean all) {
MetricsRecordBuilder mrb = metricsCollector.addRecord(metricsName);
metricsRegistry.snapshot(mrb, all);
// source is registered in supers constructor, sometimes called before the whole initialization.
if (metricsAdapter != null) {
// snapshot MetricRegistry as well
metricsAdapter.snapshotAllMetrics(registry, mrb);
}
}
Aggregations