This is an automated email from the ASF dual-hosted git repository.
leventov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-druid.git
The following commit(s) were added to refs/heads/master by this push:
new af9efdb HttpPostEmitterMonitor: don't emit maxTime and minTime if no
times were recorded (#6418)
af9efdb is described below
commit af9efdbedfa00410ede691a98daea387c8b79912
Author: Roman Leventov <[email protected]>
AuthorDate: Mon Oct 8 17:11:42 2018 -0300
HttpPostEmitterMonitor: don't emit maxTime and minTime if no times were
recorded (#6418)
* HttpPostEmitterMonitor: don't emit maxTime and minTime if no times were
recorded
* Don't emit sum and count if none
* Remove outdated comments
---
.../util/emitter/core/ConcurrentTimeCounter.java | 29 +++++++++++++++++-----
.../java/util/metrics/HttpPostEmitterMonitor.java | 18 +++++++++++---
2 files changed, 37 insertions(+), 10 deletions(-)
diff --git
a/java-util/src/main/java/org/apache/druid/java/util/emitter/core/ConcurrentTimeCounter.java
b/java-util/src/main/java/org/apache/druid/java/util/emitter/core/ConcurrentTimeCounter.java
index d4c5435..a71b2fc 100644
---
a/java-util/src/main/java/org/apache/druid/java/util/emitter/core/ConcurrentTimeCounter.java
+++
b/java-util/src/main/java/org/apache/druid/java/util/emitter/core/ConcurrentTimeCounter.java
@@ -21,6 +21,7 @@ package org.apache.druid.java.util.emitter.core;
import com.google.common.primitives.UnsignedInts;
+import javax.annotation.Nullable;
import java.util.concurrent.atomic.AtomicLong;
/**
@@ -70,18 +71,34 @@ public class ConcurrentTimeCounter
return timeSumAndCount.getAndSet(0L);
}
- public int getAndResetMaxTime()
+ /**
+ * Returns the max time {@link #add}ed since the previous call to this
method or since the creation of this object,
+ * or null if no times were added.
+ */
+ @Nullable
+ public Integer getAndResetMaxTime()
{
long max = this.max.getAndSet(-1);
- // If max < 0, means no times added yet, then return 0
- return max >= 0 ? (int) max : 0;
+ if (max >= 0) {
+ return (int) max;
+ } else {
+ return null;
+ }
}
- public int getAndResetMinTime()
+ /**
+ * Returns the min time {@link #add}ed since the previous call to this
method or since the creation of this object,
+ * or null if no times were added.
+ */
+ @Nullable
+ public Integer getAndResetMinTime()
{
long min = this.min.getAndSet(-1);
- // If min < 0, means no times added yet, then return 0
- return min >= 0 ? (int) min : 0;
+ if (min >= 0) {
+ return (int) min;
+ } else {
+ return null;
+ }
}
public static int timeSum(long timeSumAndCount)
diff --git
a/java-util/src/main/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitor.java
b/java-util/src/main/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitor.java
index de40f0e..a8fd802 100644
---
a/java-util/src/main/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitor.java
+++
b/java-util/src/main/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitor.java
@@ -75,10 +75,20 @@ public class HttpPostEmitterMonitor extends
FeedDefiningMonitor
private void emitTimeCounterMetrics(ServiceEmitter emitter,
ConcurrentTimeCounter timeCounter, String metricNameBase)
{
long timeSumAndCount = timeCounter.getTimeSumAndCountAndReset();
- emitter.emit(builder.build(metricNameBase + "timeMsSum",
ConcurrentTimeCounter.timeSum(timeSumAndCount)));
- emitter.emit(builder.build(metricNameBase + "count",
ConcurrentTimeCounter.count(timeSumAndCount)));
- emitter.emit(builder.build(metricNameBase + "maxTimeMs",
timeCounter.getAndResetMaxTime()));
- emitter.emit(builder.build(metricNameBase + "minTimeMs",
timeCounter.getAndResetMinTime()));
+ int timeSum = ConcurrentTimeCounter.timeSum(timeSumAndCount);
+ int count = ConcurrentTimeCounter.count(timeSumAndCount);
+ if (count != 0) {
+ emitter.emit(builder.build(metricNameBase + "timeMsSum", timeSum));
+ emitter.emit(builder.build(metricNameBase + "count", count));
+ }
+ Integer maxTime = timeCounter.getAndResetMaxTime();
+ if (maxTime != null) {
+ emitter.emit(builder.build(metricNameBase + "maxTimeMs", maxTime));
+ }
+ Integer minTime = timeCounter.getAndResetMinTime();
+ if (minTime != null) {
+ emitter.emit(builder.build(metricNameBase + "minTimeMs", minTime));
+ }
}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]