question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Step meters do not push incomplete step values on application shutdown

See original GitHub issue

Hi! 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:

  1. Create a new project with: https://start.spring.io/#!type=maven-project&language=java&platformVersion=2.2.5.RELEASE&packaging=jar&jvmVersion=11&groupId=com.example&artifactId=demo&name=demo&description=Demo project for Spring Boot&packageName=com.example.demo&dependencies=actuator

  2. Add a dependency on micrometer-registry-elastic

<dependency>
	<groupId>io.micrometer</groupId>
	<artifactId>micrometer-registry-elastic</artifactId>
</dependency>
  1. 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:open
  • Created 4 years ago
  • Reactions:8
  • Comments:22 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
pnaw94commented, Aug 27, 2020

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.

4reactions
shakuzencommented, Mar 24, 2021

I’ve made a note for our 1.8 planning to holistically look at our support for metrics in short-lived processes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AP Computer Science Principles Programming (Khan Academy)
The program code is shown below, but it is missing three values: <COUNTER>, <AMOUNT>, and <STEP>. i ← <COUNTER> REPEAT <AMOUNT> TIMES {...
Read more >
Odd & Sporadic Chrome Error: The chunked cookie is ...
a. Then again click the “RELAUNCH” button. IF it still does not work, then follow these steps… Try to access our application ......
Read more >
Spring Boot Reference Documentation
Try the How-to documents. They provide solutions to the most common questions. Learn the Spring basics. Spring Boot builds on many other Spring...
Read more >
Maximum Likelihood from Incomplete Data via the EM Algorithm
but Sundberg's formulae no longer apply directly, so we must replace the M-step by: M-step: Determine +(p+l) to be a value of +...
Read more >
Maximum Likelihood from Incomplete Data via the EM ... - JStor
but Sundberg's formulae no longer apply directly, so we must replace the M-step by: M-step: Determine c)(P+1) to be a value of co...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found