Skip to content

Commit

Permalink
Merge branch '1.14.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatan-ivanov committed Jan 29, 2025
2 parents 074e351 + b19d96c commit 1f43511
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,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 @@ -36,6 +36,7 @@
import java.io.IOException;
import java.time.Duration;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicInteger;

import static java.util.Collections.emptyList;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -186,6 +187,27 @@ void asyncLogShouldNotBeDuplicated() throws IOException {
.until(() -> registry.get("log4j2.events").tags("level", "info").counter().count() == 3);
}

// see https://github.com/micrometer-metrics/micrometer/pull/872
@Test
void shouldTriggerLoggersUpdateOnOpenAndClose() {
LoggerContext context = new LoggerContext("test");

AtomicInteger reconfigureCount = new AtomicInteger();
context.addPropertyChangeListener(event -> {
if (event.getNewValue() instanceof Configuration) {
reconfigureCount.incrementAndGet();
}
});

Log4j2Metrics metrics = new Log4j2Metrics(emptyList(), context);

assertThat(reconfigureCount.get()).isEqualTo(0);
metrics.bindTo(registry);
assertThat(reconfigureCount.get()).isEqualTo(1);
metrics.close();
assertThat(reconfigureCount.get()).isEqualTo(2);
}

@Test
void metricsFilterIsReused() {
LoggerContext loggerContext = new LoggerContext("test");
Expand Down
Loading

0 comments on commit 1f43511

Please sign in to comment.