-
Notifications
You must be signed in to change notification settings - Fork 646
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creates SystemStatusController and SystemMetricsService for status in…
…fo UI + Defines functions to get stats and queue info from Sidekiq
- Loading branch information
1 parent
a8b016d
commit d19a4a0
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class SystemStatusController < ApplicationController | ||
# service = SystemMetricsService.new | ||
end |
This file contains 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'sidekiq/api' | ||
|
||
class SystemMetricsService | ||
def initialize | ||
@queues = YAML.load_file('config/sidekiq.yml')[:queues] | ||
fetch_sidekiq_stats | ||
end | ||
|
||
def fetch_sidekiq_stats | ||
stats = Sidekiq::Stats.new | ||
|
||
@processed_jobs_stat = stats.processed | ||
@failed_jobs_stat = stats.failed # Failed Job Retention | ||
@enqueued_jobs_stat = stats.enqueued | ||
@scheduled_jobs_stat = stats.scheduled_size | ||
|
||
# also allow stats from selected dates to be viewed | ||
# using Stats::History | ||
end | ||
|
||
# def fetch_system_health_metrics | ||
# end | ||
|
||
# def fetch_reliability_metrics | ||
# end | ||
|
||
# def fetch_availability_metrics | ||
# end | ||
|
||
# def fetch_processing_efficiency_metrics | ||
# end | ||
|
||
# def fetch_resource_utilization_metrics | ||
# end | ||
|
||
def fetch_queue_management_metrics | ||
# Queue latency; how long jobs wait in the queue before processing | ||
@queues.map do |queue_name| | ||
queue = Sidekiq::Queue.new(queue_name) | ||
{ | ||
name: queue.name, | ||
size: queue.size, | ||
latency: queue.latency | ||
} | ||
end | ||
end | ||
|
||
# def fetch_data_freshness_metrics | ||
# end | ||
end |