diff --git a/spectator-ext-gc/src/main/java/com/netflix/spectator/gc/GcLogger.java b/spectator-ext-gc/src/main/java/com/netflix/spectator/gc/GcLogger.java index 35a4b5218..1a90befab 100644 --- a/spectator-ext-gc/src/main/java/com/netflix/spectator/gc/GcLogger.java +++ b/spectator-ext-gc/src/main/java/com/netflix/spectator/gc/GcLogger.java @@ -252,7 +252,8 @@ private void processGcEvent(GarbageCollectionNotificationInfo info) { .withTag("action", info.getGcAction()) .withTag("cause", info.getGcCause()); Timer timer = Spectator.globalRegistry().timer(eventId); - timer.record(info.getGcInfo().getDuration(), TimeUnit.MILLISECONDS); + long duration = Math.max(1, info.getGcInfo().getDuration()); + timer.record(duration, TimeUnit.MILLISECONDS); // Update promotion and allocation counters updateMetrics(info.getGcName(), info.getGcInfo());