confluentinc / confluentinc/rest-utils

Is WindowedCount the right stat type to use in MetricsResourceMethodApplicationListener?

Open
#344 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
25
Forks
211
Avg merge
14h 33m
Merged PRs (30d)
3

Description

By default, an application is [configured](https://github.com/confluentinc/rest-utils/blob/67d9b070e700a5807ab584d51771ed7f92c2b255/core/src/main/java/io/confluent/rest/Application.java#L173) to keep two samples in a `SampledStat`, e.g., `WindowedCount`, each sample maintains a 30-second window. Typically, metrics are exposed by `JmxReporter`. When the value of an MBean is being retrieved, it calls the stat's `measure` method. In `WindowedCount`, `measure` simply combines all data points in all (two) samples to get the sum. Unless the MBean retrievals are well aligned with the start of a window with the intervals being (window size * # of samples), I don't see how it could report the right count.

For instance:
T: 0----5----[10]----15----[20]----25----[30]
W: |-----1-----|------2------|------3-------|

Let's assume the window size is 10, the metrics get collected every 10 seconds.
Collection 1 at 15: it returns the sum of (full window 1 and half of window 2), i.e., 0-15
Collection 2 at 25: it returns the sum of (full window 2 and half of window 3), i.e., 10-25
In this example, the values between 10-15 are repeatedly reported.

Can anyone please verify if this is the right understanding?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.