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

Add helper method to query the latency on the Queue object #415

Merged
merged 3 commits into from
Dec 1, 2024

Conversation

andersonkrs
Copy link
Contributor

Hey all!

I'm using Yabeda to collect some metrics on a rails app that uses solid_queue. I send some metrics like the latency on each queue. Currently I use a little patch to accomplish that. I wonder if we can upstream this path just to make it more convenient for other people to access solid_queue's API. 🤔

My Yabeda config example

Yabeda.configure do
  group :solid_queue do
    gauge :queue_latency, unit: :seconds, tags: [:queue]
  end

  collect do
    SolidQueue::Queue.all.each do |queue|
      solid_queue.queue_latency.set({ queue: queue.name }, queue.latency)
    end
  end
end

@@ -40,6 +40,19 @@ def size
@size ||= ReadyExecution.queued_as(name).count
end

def latency
@latency = begin
Copy link
Member

Choose a reason for hiding this comment

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

Was this perhaps intended to be

@latency ||= begin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ooh good catch! 🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just fixed it and created a test for the memoization!

Copy link
Member

@rosa rosa left a comment

Choose a reason for hiding this comment

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

Hey @andersonkrs, thanks so much for this and sorry for the delay! I just left a couple of minor comments but this is great 🙏

@andersonkrs andersonkrs requested a review from rosa December 1, 2024 16:16
@andersonkrs
Copy link
Contributor Author

Hey @rosa thank you for the review, I just updated the PR with the suggestions!

Copy link
Member

@rosa rosa left a comment

Choose a reason for hiding this comment

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

Awesome, thank you so much! 🙏

@rosa rosa merged commit fabf713 into rails:main Dec 1, 2024
4 checks passed
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