HADOOP-14892. MetricsSystemImpl should use Time.monotonicNow for measuring durations. Contributed by Chetna Chaudhari.
This commit is contained in:
parent
02e2a9b115
commit
3a10367a17
@ -415,10 +415,10 @@ public synchronized MetricsBuffer sampleMetrics() {
|
|||||||
|
|
||||||
private void snapshotMetrics(MetricsSourceAdapter sa,
|
private void snapshotMetrics(MetricsSourceAdapter sa,
|
||||||
MetricsBufferBuilder bufferBuilder) {
|
MetricsBufferBuilder bufferBuilder) {
|
||||||
long startTime = Time.now();
|
long startTime = Time.monotonicNow();
|
||||||
bufferBuilder.add(sa.name(), sa.getMetrics(collector, true));
|
bufferBuilder.add(sa.name(), sa.getMetrics(collector, true));
|
||||||
collector.clear();
|
collector.clear();
|
||||||
snapshotStat.add(Time.now() - startTime);
|
snapshotStat.add(Time.monotonicNow() - startTime);
|
||||||
LOG.debug("Snapshotted source "+ sa.name());
|
LOG.debug("Snapshotted source "+ sa.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,7 +431,7 @@ private void snapshotMetrics(MetricsSourceAdapter sa,
|
|||||||
synchronized void publishMetrics(MetricsBuffer buffer, boolean immediate) {
|
synchronized void publishMetrics(MetricsBuffer buffer, boolean immediate) {
|
||||||
int dropped = 0;
|
int dropped = 0;
|
||||||
for (MetricsSinkAdapter sa : sinks.values()) {
|
for (MetricsSinkAdapter sa : sinks.values()) {
|
||||||
long startTime = Time.now();
|
long startTime = Time.monotonicNow();
|
||||||
boolean result;
|
boolean result;
|
||||||
if (immediate) {
|
if (immediate) {
|
||||||
result = sa.putMetricsImmediate(buffer);
|
result = sa.putMetricsImmediate(buffer);
|
||||||
@ -439,7 +439,7 @@ synchronized void publishMetrics(MetricsBuffer buffer, boolean immediate) {
|
|||||||
result = sa.putMetrics(buffer, logicalTime);
|
result = sa.putMetrics(buffer, logicalTime);
|
||||||
}
|
}
|
||||||
dropped += result ? 0 : 1;
|
dropped += result ? 0 : 1;
|
||||||
publishStat.add(Time.now() - startTime);
|
publishStat.add(Time.monotonicNow() - startTime);
|
||||||
}
|
}
|
||||||
droppedPubAll.incr(dropped);
|
droppedPubAll.incr(dropped);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user