Skip to content

Commit

Permalink
Fix unit discrepancy between Timer and FunctionTimer in LoggingMeterR…
Browse files Browse the repository at this point in the history
…egistry

Closes gh-5816
  • Loading branch information
jonatan-ivanov committed Jan 28, 2025
1 parent cb2957d commit 5156f79
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ protected void publish() {
double count = timer.count();
if (!config.logInactive() && count == 0)
return;
loggingSink.accept(print.id() + " throughput=" + print.rate(count) + " mean="
loggingSink.accept(print.id() + " throughput=" + print.unitlessRate(count) + " mean="
+ print.time(timer.mean(getBaseTimeUnit())));
}, meter -> loggingSink.accept(writeMeter(meter, print)));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ void publishShouldPrintDeltaCountAndThroughputWhenMeterIsFunctionTimer() {
recordingRegistry.more().timer("my.function-timer", emptyList(), new AtomicDouble(), d -> 30, d -> 30, SECONDS);
clock.add(config.step());
recordingRegistry.publish();
assertThat(recordingRegistry.getLogs())
.containsExactly("my.function-timer{} throughput=0.5 milliseconds/s mean=1s");
assertThat(recordingRegistry.getLogs()).containsExactly("my.function-timer{} throughput=0.5/s mean=1s");
}

@Test
Expand Down Expand Up @@ -319,7 +318,7 @@ void publishShouldPrintMetersWithZeroStepCountWhenLogsInactiveIsEnabled() {
assertThat(recordingRegistry.getMeters()).hasSize(5);
assertThat(recordingRegistry.getLogs()).containsExactlyInAnyOrder("my.counter{} throughput=0/s",
"my.timer{} throughput=0/s mean= max=", "my.summary{} throughput=0/s mean=0 max=0",
"my.function-counter{} throughput=0/s", "my.function-timer{} throughput=0 milliseconds/s mean=");
"my.function-counter{} throughput=0/s", "my.function-timer{} throughput=0/s mean=");
}

private static class TestConfig implements LoggingRegistryConfig {
Expand Down

0 comments on commit 5156f79

Please sign in to comment.