Skip to content
Permalink
Browse files
fix messageGap metric (#12337)
  • Loading branch information
yuanlihan committed Mar 28, 2022
1 parent 9c6b9ab commit f2495a67d206534b6ee79b083ce49b3131165192
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
@@ -263,7 +263,8 @@ public FireDepartmentMetrics snapshot()
retVal.messageMaxTimestamp.set(messageMaxTimestamp.get());
retVal.messageProcessingCompletionTime.set(messageProcessingCompletionTime.get());
retVal.messageProcessingCompletionTime.compareAndSet(DEFAULT_PROCESSING_COMPLETION_TIME, System.currentTimeMillis());
retVal.messageGap.set(retVal.messageProcessingCompletionTime.get() - messageMaxTimestamp.get());
long maxTimestamp = retVal.messageMaxTimestamp.get();
retVal.messageGap.set(maxTimestamp > 0 ? retVal.messageProcessingCompletionTime.get() - maxTimestamp : 0L);
return retVal;
}
}
@@ -33,6 +33,12 @@ public void setup()
metrics = new FireDepartmentMetrics();
}

@Test
public void testSnapshotBeforeProcessing()
{
Assert.assertEquals(0L, metrics.snapshot().messageGap());
}

@Test
public void testSnapshotAfterProcessingOver()
{

0 comments on commit f2495a6

Please sign in to comment.