-
Notifications
You must be signed in to change notification settings - Fork 17
Adds metrics on how different queues have different thread amounts allocated to them #37
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
hbontempo-br
wants to merge
2
commits into
yabeda-rb:master
Choose a base branch
from
hbontempo-br:feature/process_metrics
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,15 +53,30 @@ def self.config | |
if config.collect_cluster_metrics # defaults to +::Sidekiq.server?+ | ||
retry_count_tags = config.retries_segmented_by_queue ? %i[queue] : [] | ||
|
||
gauge :jobs_waiting_count, tags: %i[queue], aggregation: :most_recent, comment: "The number of jobs waiting to process in sidekiq." | ||
gauge :active_workers_count, tags: [], aggregation: :most_recent, | ||
comment: "The number of currently running machines with sidekiq workers." | ||
gauge :jobs_scheduled_count, tags: [], aggregation: :most_recent, comment: "The number of jobs scheduled for later execution." | ||
gauge :jobs_retry_count, tags: retry_count_tags, aggregation: :most_recent, comment: "The number of failed jobs waiting to be retried" | ||
gauge :jobs_dead_count, tags: [], aggregation: :most_recent, comment: "The number of jobs exceeded their retry count." | ||
gauge :active_processes, tags: [], aggregation: :most_recent, comment: "The number of active Sidekiq worker processes." | ||
gauge :queue_latency, tags: %i[queue], aggregation: :most_recent, | ||
comment: "The queue latency, the difference in seconds since the oldest job in the queue was enqueued" | ||
gauge :jobs_waiting_count, tags: %i[queue], aggregation: :most_recent, | ||
comment: "The number of jobs waiting to process in sidekiq." | ||
gauge :active_workers_count, tags: [], aggregation: :most_recent, | ||
comment: "Total number of sidekiq workers threads." | ||
gauge :busy_workers_count, tags: [], aggregation: :most_recent, | ||
comment: "Number of busy sidekiq workers threads." | ||
gauge :available_workers_count, tags: [], aggregation: :most_recent, | ||
comment: "Number of busy sidekiq workers threads." | ||
gauge :active_workers_count_per_queue, tags: %i[queue], aggregation: :most_recent, | ||
comment: "Total number of sidekiq workers threads that can process a given queue." | ||
gauge :busy_workers_count_per_queue, tags: %i[queue], aggregation: :most_recent, | ||
comment: "Number of busy sidekiq workers threads that can process a given queue." | ||
gauge :available_workers_count_per_queue, tags: %i[queue], aggregation: :most_recent, | ||
comment: "Number of busy sidekiq workers threads that can process a given queue." | ||
gauge :jobs_scheduled_count, tags: [], aggregation: :most_recent, | ||
comment: "The number of jobs scheduled for later execution." | ||
gauge :jobs_retry_count, tags: retry_count_tags, aggregation: :most_recent, | ||
comment: "The number of failed jobs waiting to be retried" | ||
gauge :jobs_dead_count, tags: [], aggregation: :most_recent, | ||
comment: "The number of jobs exceeded their retry count." | ||
gauge :active_processes, tags: [], aggregation: :most_recent, | ||
comment: "The number of active Sidekiq worker processes." | ||
gauge :queue_latency, tags: %i[queue], aggregation: :most_recent, | ||
comment: "The queue latency, the difference in seconds since the oldest job in the queue was enqueued" | ||
end | ||
|
||
collect do | ||
|
@@ -70,15 +85,36 @@ def self.config | |
next unless config.collect_cluster_metrics | ||
|
||
stats = ::Sidekiq::Stats.new | ||
|
||
stats.queues.each do |k, v| | ||
sidekiq_jobs_waiting_count.set({ queue: k }, v) | ||
end | ||
sidekiq_active_workers_count.set({}, stats.workers_size) | ||
sidekiq_jobs_scheduled_count.set({}, stats.scheduled_size) | ||
sidekiq_jobs_dead_count.set({}, stats.dead_size) | ||
sidekiq_active_processes.set({}, stats.processes_size) | ||
|
||
process_data = { active: 0, busy: 0, available: 0 } | ||
queue_data = {} | ||
::Sidekiq::ProcessSet.new.each do |process| | ||
process_data[:active] += process['concurrency'] | ||
process_data[:busy] += process['busy'] | ||
process_data[:available] += process['concurrency'] - process['busy'] | ||
process['queues'].each do |queue| | ||
queue_data[queue] ||= { active: 0, busy: 0, available: 0 } | ||
queue_data[queue][:active] += process['concurrency'] | ||
queue_data[queue][:busy] += process['busy'] | ||
queue_data[queue][:available] += process['concurrency'] - process['busy'] | ||
end | ||
end | ||
sidekiq_active_workers_count.set({}, process_data[:active]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is |
||
sidekiq_busy_workers_count.set({}, process_data[:busy]) | ||
sidekiq_available_workers_count.set({}, process_data[:available]) | ||
queue_data.each do |queue, data| | ||
labels = { queue: queue } | ||
sidekiq_active_workers_count_per_queue.set(labels, data[:active]) | ||
sidekiq_busy_workers_count_per_queue.set(labels, data[:busy]) | ||
sidekiq_available_workers_count_per_queue.set(labels, data[:available]) | ||
end | ||
|
||
::Sidekiq::Queue.all.each do |queue| | ||
sidekiq_queue_latency.set({ queue: queue.name }, queue.latency) | ||
end | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of calculating available threads number here? It can be calculated in the monitoring system as well