Skip to content

Feat[MQBSTAT]: Add queue utilization metrics #678

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

alexander-e1off
Copy link
Collaborator

Add two new queue metrics representing queue utilization (in precents):

  • queue messages utilization: queue.content_msgs / queue.cfg_msgs * 100%;
  • queue bytes utilization: queue.content_bytes/ queue.cfg_bytes * 100%;

Signed-off-by: Aleksandr Ivanov <[email protected]>
@alexander-e1off alexander-e1off requested a review from a team as a code owner April 2, 2025 12:49
@chrisbeard chrisbeard self-assigned this Apr 2, 2025
Comment on lines 111 to 122
double avg = 0;
if (latestSnapshot > oldestSnapshot) {
avg = bmqst::StatUtil::average(
context.value(bmqst::StatContext::e_DIRECT_VALUE, currentValue),
latestSnapshot,
oldestSnapshot);
}
else {
avg = static_cast<double>(bmqst::StatUtil::value(
context.value(bmqst::StatContext::e_DIRECT_VALUE, currentValue),
latestSnapshot));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the exact semantic of the calculated value? Is it "current utilization", "max utilization", etc?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I consider that utilization is calculated as average value of current messages/bytes within publish period divided by limit value. Snapshot interval is usually 1 sec, publish interval is usually 10 sec. So, the average value of messages/bytes for the last 10 snapshots is calculated. Added comments into the code describing this logic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep the semantics aligned with the existing history metrics, which are either current or max. Given the choice between the two, I think max is the more useful option. Domains already provide the ability to alarm (internally in the broker) if capacity crosses a threshold (e.g. 80% full), so exposing that max would be the the closest stat to the stat triggering that alarm.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, refactored to use max value for calculation of queue utilization.

@@ -110,8 +110,10 @@ class QueueStatsDomain {
e_NB_CONSUMER,
e_MESSAGES_CURRENT,
e_MESSAGES_MAX,
e_MESSAGES_UTILIZATION,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about ending with "_MAX" to make it clear it's peak utilization? Otherwise, lgtm.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, added suffix _MAX to the new metrics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants