Step meters do not push incomplete step values on application shutdown
See original GitHub issueHi! Had posted this in Slack, but thought to report it here as well pending response there
In short: I have a Spring Boot 2.2.5 application with spring-boot-starter-actuator
and micrometer-registry-elastic
; when I set management.metrics.export.elastic.enabled=true
, then my counters do not increment anymore.
Not sure if this should be a micrometer issue or related to Spring Boot; ElasticMeterRegistry
is in micrometer whereas ElasticMetricsExportAutoConfiguration
is in Spring Boot. But since the latter seems to mostly delegate and is rather minimal otherwise, I thought to report it here first.
To replicate the problem:
-
Add a dependency on micrometer-registry-elastic
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-elastic</artifactId>
</dependency>
- Create a test class containing
@Test
void counterStaysAtZero() {
DebugApplication.main("", "--management.metrics.export.elastic.enabled=true");
// DebugApplication : Counter: 0.0 , [Measurement{statistic='COUNT', value=0.0}]
// DebugApplication : Counter: 0.0 , [Measurement{statistic='COUNT', value=0.0}]
}
@Test
void counterAddsToOne() {
DebugApplication.main("", "--management.metrics.export.elastic.enabled=false");
// DebugApplication : Counter: 0.0 , [Measurement{statistic='COUNT', value=0.0}]
// DebugApplication : Counter: 1.0 , [Measurement{statistic='COUNT', value=1.0}]
}
@SpringBootApplication
@RequiredArgsConstructor
@Slf4j
public static class DebugApplication implements ApplicationRunner {
public static void main(String... args) {
log.info("{}", args[1]);
SpringApplication.run(DebugApplication.class, args).close();
}
private final MeterRegistry registry;
@Override
public void run(ApplicationArguments args) throws Exception {
Counter counter = registry.counter("someCounter");
log.info("Counter: {} , {}", counter.count(), counter.measure());
counter.increment();
log.info("Counter: {} , {}", counter.count(), counter.measure());
}
}
If you then run both tests you will get the log output that’s listed in each test method.
I would expect the Counter to increment regardless of whether metrics are exported; What can be done to make this so the counters increase?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:22 (7 by maintainers)
Top GitHub Comments
Would really appreciate this one.
We run a big-data processing platform with a large number of processes, both long and short lived (where short-lived is even <10s, and long-lived even several hours, and we can’t easily assume upfront whether a process will be short or long living), and we essentially have the same issue here - metrics from short-lived processes are not being published, therefore we really only have a subset of our processes being measured.
Putting a thread sleep call is not ideal for us, as due to high number of short-lived processes we run, this might raise our costs significantly. I can also see that there is a possibility of reducing this step size, but then I’m concerned about potential performance impact on long-running processes.
@shakuzen I’m wondering if you could recommend a preferred approach here. Perhaps we can modify the step at runtime? I’m not sure however if it’s realistically achievable. I’d really appreciate your feedback on this.
I’ve made a note for our 1.8 planning to holistically look at our support for metrics in short-lived processes.