Skip to content

Commit

Permalink
Fix LongTaskTimer output for LoggingMeterRegistryTest
Browse files Browse the repository at this point in the history
Closes gh-5834
  • Loading branch information
jonatan-ivanov committed Jan 28, 2025
1 parent 5156f79 commit 04eef90
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.util.stream.StreamSupport;

import static io.micrometer.core.instrument.util.DoubleFormat.decimalOrNan;
import static io.micrometer.core.instrument.util.DoubleFormat.wholeOrDecimal;
import static java.util.stream.Collectors.joining;

/**
Expand Down Expand Up @@ -146,7 +147,7 @@ protected void publish() {
int activeTasks = longTaskTimer.activeTasks();
if (!config.logInactive() && activeTasks == 0)
return;
loggingSink.accept(print.id() + " active=" + print.value(activeTasks) + " duration="
loggingSink.accept(print.id() + " active=" + wholeOrDecimal(activeTasks) + " duration="
+ print.time(longTaskTimer.duration(getBaseTimeUnit())));
}, timeGauge -> {
double value = timeGauge.value(getBaseTimeUnit());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void publishShouldPrintActiveCountAndDurationWhenMeterIsLongTaskTimer() {
IntStream.rangeClosed(1, 30).forEach(t -> timer.start());
clock.add(config.step());
recordingRegistry.publish();
assertThat(recordingRegistry.getLogs()).containsExactly("my.ltt{} active=30 milliseconds duration=30m");
assertThat(recordingRegistry.getLogs()).containsExactly("my.ltt{} active=30 duration=30m");
}

@Test
Expand Down

0 comments on commit 04eef90

Please sign in to comment.