use of org.apache.hadoop.metrics2.MetricsCollector in project hadoop by apache.
the class DecayRpcScheduler method getMetrics.
@Override
public void getMetrics(MetricsCollector collector, boolean all) {
// Metrics2 interface to act as a Metric source
try {
MetricsRecordBuilder rb = collector.addRecord(getClass().getName()).setContext(namespace);
addDecayedCallVolume(rb);
addUniqueIdentityCount(rb);
addTopNCallerSummary(rb);
addAvgResponseTimePerPriority(rb);
addCallVolumePerPriority(rb);
addRawCallVolume(rb);
} catch (Exception e) {
LOG.warn("Exception thrown while metric collection. Exception : " + e.getMessage());
}
}
use of org.apache.hadoop.metrics2.MetricsCollector in project hadoop by apache.
the class MetricsSystemImpl method getMetrics.
@Override
public synchronized void getMetrics(MetricsCollector builder, boolean all) {
MetricsRecordBuilder rb = builder.addRecord(MS_NAME).addGauge(MsInfo.NumActiveSources, sources.size()).addGauge(MsInfo.NumAllSources, allSources.size()).addGauge(MsInfo.NumActiveSinks, sinks.size()).addGauge(MsInfo.NumAllSinks, allSinks.size());
for (MetricsSinkAdapter sa : sinks.values()) {
sa.snapshot(rb, all);
}
registry.snapshot(rb, all);
}
use of org.apache.hadoop.metrics2.MetricsCollector in project hadoop by apache.
the class TestMetricsAnnotations method testClasses.
@Test
public void testClasses() {
MetricsRecordBuilder rb = getMetrics(MetricsAnnotations.makeSource(new MyMetrics3()));
MetricsCollector collector = rb.parent();
verify(collector).addRecord(info("MyMetrics3", "My metrics"));
verify(rb).add(tag(MsInfo.Context, "foo"));
}
use of org.apache.hadoop.metrics2.MetricsCollector in project hadoop by apache.
the class TestTopMetrics method testPresence.
@Test
public void testPresence() {
Configuration conf = new Configuration();
TopConf topConf = new TopConf(conf);
TopMetrics topMetrics = new TopMetrics(conf, topConf.nntopReportingPeriodsMs);
// Dummy command
topMetrics.report("test", "listStatus");
topMetrics.report("test", "listStatus");
topMetrics.report("test", "listStatus");
MetricsRecordBuilder rb = getMetrics(topMetrics);
MetricsCollector mc = rb.parent();
verify(mc).addRecord(TOPMETRICS_METRICS_SOURCE_NAME + ".windowMs=60000");
verify(mc).addRecord(TOPMETRICS_METRICS_SOURCE_NAME + ".windowMs=300000");
verify(mc).addRecord(TOPMETRICS_METRICS_SOURCE_NAME + ".windowMs=1500000");
verify(rb, times(3)).addCounter(Interns.info("op=listStatus.TotalCount", "Total operation count"), 3L);
verify(rb, times(3)).addCounter(Interns.info("op=*.TotalCount", "Total operation count"), 3L);
verify(rb, times(3)).addCounter(Interns.info("op=listStatus." + "user=test.count", "Total operations performed by user"), 3L);
}
Aggregations