Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timer did not reset after expire time. #2751

Closed
LatsykNS opened this issue Aug 16, 2021 · 6 comments
Closed

Timer did not reset after expire time. #2751

LatsykNS opened this issue Aug 16, 2021 · 6 comments
Labels
closed-as-inactive doc-update A documentation update module: micrometer-core An issue that is related to our core module question A user question, probably better suited for StackOverflow

Comments

@LatsykNS
Copy link

LatsykNS commented Aug 16, 2021

Hi, I have implemented a very simple configuration to use Prometheus Timer :

Config:

@Bean
  public PrometheusMeterRegistry meterRegistry () {
    return new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
 }

Start-Stop Timer code with 1 hour expire time:

Timer.start(meterRegistry);
// some code
sample.stop(Timer.builder("my_endpoint")
       .publishPercentiles(0.95)
       .sla(ofMillis(1), ofMillis(500), ofMillis(1000),
           ofMillis(1500), ofMillis(2000),
           ofMinutes(2500), ofMillis(3000),
           ofMillis(3500), ofMillis(4000), ofMillis(5000))
       .distributionStatisticExpiry(Duration.ofHours(1))
       .register(meterRegistry)); 

However, during 1 hour I did not make any requests, but the current max time was still there:

TYPE my_endpoint_seconds_max gauge
my_endpoint_seconds_max 0.814347704

It expired after 2+ hours.

Dependencies:
io.micrometer:micrometer-spring-legacy:1.3.20
io.micrometer:micrometer-registry-prometheus:1.7.2

Could you please answer what is wrong? Maybe my understanding of Timer expiry time is incorrect.

@shakuzen shakuzen added doc-update A documentation update question A user question, probably better suited for StackOverflow labels Aug 19, 2021
@shakuzen
Copy link
Member

Firstly, you are using different versions of micrometer dependencies, which is likely to cause issues. Also, micrometer-spring-legacy is no longer supported.

To answer your question, expiration of distribution statistics happens via a ring buffer. The expiration behavior is controlled by the ring buffer length and the time between rotation. The expiry duration set in your example controls the time between rotation. By default, the ring buffer has a length of 3. So it will take the buffer length * the rotation duration for a value to completely expire.

Admittedly, this could be explained better in the reference documentation and is not intuitive from the method name. It is explained in the JavaDocs for related methods already, though. https://www.javadoc.io/doc/io.micrometer/micrometer-core/latest/io/micrometer/core/instrument/AbstractTimerBuilder.html

Statistics emanating from a timer like max, percentiles, and histogram counts decay over time to give greater weight to recent samples (exception: histogram counts are cumulative for those systems that expect cumulative histogram buckets). Samples are accumulated to such statistics in ring buffers which rotate after this expiry, with a buffer length of distributionStatisticBufferLength(Integer).

Looking forward, we could migrate the API to make the method names more intuitive. Perhaps something like expiryRotationTime? Suggestions welcome.

@shakuzen shakuzen added the module: micrometer-core An issue that is related to our core module label Aug 20, 2021
@LatsykNS
Copy link
Author

LatsykNS commented Dec 1, 2021

Hi @shakuzen , can you please provide a compatibility table between micrometer and prometheus libs ?

@LatsykNS
Copy link
Author

LatsykNS commented Dec 1, 2021

@shakuzen, from the method description it is not fully clear what is complete expire time. Is it possible to update the documentation with the info like: completely expire time = buffer length (distributionStatisticBufferLength) * the rotation duration (distributionStatisticExpiry)?

@marcingrzejszczak
Copy link
Contributor

Is this still a problem with the latest versions?

@marcingrzejszczak marcingrzejszczak added the waiting for feedback We need additional information before we can continue label Dec 20, 2023
Copy link

github-actions bot commented Jan 2, 2024

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Copy link

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-as-inactive doc-update A documentation update module: micrometer-core An issue that is related to our core module question A user question, probably better suited for StackOverflow
Projects
None yet
Development

No branches or pull requests

4 participants