Skip to content

Commit bc53fa6

Browse files
committed
Avoid 0 duration GC event times
1 parent 1e44427 commit bc53fa6

File tree

1 file changed

+2
-1
lines changed
  • spectator-ext-gc/src/main/java/com/netflix/spectator/gc

1 file changed

+2
-1
lines changed

Diff for: spectator-ext-gc/src/main/java/com/netflix/spectator/gc/GcLogger.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ private void processGcEvent(GarbageCollectionNotificationInfo info) {
252252
.withTag("action", info.getGcAction())
253253
.withTag("cause", info.getGcCause());
254254
Timer timer = Spectator.globalRegistry().timer(eventId);
255-
timer.record(info.getGcInfo().getDuration(), TimeUnit.MILLISECONDS);
255+
long duration = Math.max(1, info.getGcInfo().getDuration());
256+
timer.record(duration, TimeUnit.MILLISECONDS);
256257

257258
// Update promotion and allocation counters
258259
updateMetrics(info.getGcName(), info.getGcInfo());

0 commit comments

Comments
 (0)