Skip to content

Commit

Permalink
Add log for negative amount in AbstractTimer.record()
Browse files Browse the repository at this point in the history
  • Loading branch information
izeye committed Jan 16, 2024
1 parent 74b5cfc commit 8650979
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package io.micrometer.core.instrument;

import io.micrometer.common.lang.Nullable;
import io.micrometer.common.util.internal.logging.WarnThenDebugLogger;
import io.micrometer.core.instrument.distribution.*;
import io.micrometer.core.instrument.distribution.pause.ClockDriftPauseDetector;
import io.micrometer.core.instrument.distribution.pause.NoPauseDetector;
Expand All @@ -36,6 +37,8 @@

public abstract class AbstractTimer extends AbstractMeter implements Timer {

private static final WarnThenDebugLogger log = new WarnThenDebugLogger(AbstractTimer.class);

private static final Map<PauseDetector, Object> pauseDetectorCache = new ConcurrentHashMap<>();

protected final Clock clock;
Expand Down Expand Up @@ -262,6 +265,9 @@ public final void record(long amount, TimeUnit unit) {
((IntervalEstimator) intervalEstimator).recordInterval(clock.monotonicTime());
}
}
else {
log.log(() -> "'amount' should not be negative but was: " + amount);
}
}

protected abstract void recordNonNegative(long amount, TimeUnit unit);
Expand Down

0 comments on commit 8650979

Please sign in to comment.