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

fix(1170): Use scope guard to decrement reducer queue length #1172

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

joshua-spacetime
Copy link
Collaborator

Fixes #1170.

Also updates the bucket values for the queue length histogram. Also removes the max queue length metric, since the histogram should suffice.

Description of Changes

Please describe your change, mention any related tickets, and so on here.

API and ABI breaking changes

If this is an API or ABI breaking change, please apply the
corresponding GitHub label.

Expected complexity level and risk

How complicated do you think these changes are? Grade on a scale from 1 to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex change.

This complexity rating applies not only to the complexity apparent in the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning ways.

Testing

Describe any testing you've done, and any testing you'd like your reviewers to do,
so that you're confident that all the changes work as expected!

  • Write a test you've completed here.
  • Write a test you want a reviewer to do here, so they can check it off when they're satisfied.

Fixes #1170.

Also updates the bucket values for the queue length histogram.
Also removes the max queue length metric, since the histogram should suffice.
Comment on lines +91 to 92
let _guard = QueueMetric::inc(db);
let permit = acq.await.map_err(|_| PoolClosed)?;
Copy link
Collaborator Author

@joshua-spacetime joshua-spacetime Apr 26, 2024

Choose a reason for hiding this comment

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

I'm fairly confident we should not have any more issues with this metric not resetting, or this metric going negative, with this scope guard in place. Would you agree @coolreader18?

Copy link
Collaborator

@coolreader18 coolreader18 left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +61 to +65
let queue_length = WORKER_METRICS.instance_queue_length.with_label_values(&self.db).get();
WORKER_METRICS
.instance_queue_length_histogram
.with_label_values(&self.db)
.observe(queue_length as f64);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need a separate histogram? shouldn't grafana accumulate the data for us over time anyway?

Copy link
Collaborator

@coolreader18 coolreader18 Apr 29, 2024

Choose a reason for hiding this comment

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

if you didn't need to set the histogram you could just use the inc_scope utility function I made a while ago, which does this same sorta thing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

why do we need a separate histogram? shouldn't grafana accumulate the data for us over time anyway?

The instance_queue_length metric is a gauge which is only sampled once per sampling interval. So all it gives us is the queue length at the end of the sampling interval over time. But it doesn't tell us anything about the queue length at the beginning or middle of the sampling interval.

instance_queue_length_histogram on the other hand will build a histogram of all the different values the queue length takes throughout the sampling interval, and this will give us percentiles.

It is true that instance_queue_length really doesn't give us any new information over the histogram. We just need some variable to track the current length of the queue. I just chose a prometheus metric for that purpose mainly for ease of use.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you could just use the inc_scope utility function I made a while ago

I would have done that if it weren't for the get

@bfops bfops added the release-any To be landed in any release window label Apr 29, 2024
@joshua-spacetime joshua-spacetime added this pull request to the merge queue Apr 29, 2024
Merged via the queue into master with commit fc3ff30 Apr 29, 2024
7 checks passed
@joshua-spacetime joshua-spacetime deleted the joshua/fix/1170/reducer-queue-length branch April 29, 2024 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-any To be landed in any release window
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix reducer queue length metric
3 participants