Class: PatientHttp::Sidekiq::WebUI
- Inherits:
-
Object
- Object
- PatientHttp::Sidekiq::WebUI
- Defined in:
- lib/patient_http/sidekiq/web_ui.rb
Overview
Web UI extension for Sidekiq Adds an "Async HTTP" tab to the main Sidekiq dashboard Works with Sidekiq 7.3+ and 8.0+
Constant Summary collapse
- ROOT =
File.join(__dir__, "web_ui")
- VIEWS =
File.join(ROOT, "views")
Class Method Summary collapse
-
.registered(app) ⇒ Object
This method is called by Sidekiq::Web when registering the extension.
-
.template ⇒ Object
Sidekiq resolves symbol view names to different file names depending on the version (*.erb before 8.1, *.html.erb from 8.1 on), so the template is rendered from a string instead.
Class Method Details
.registered(app) ⇒ Object
This method is called by Sidekiq::Web when registering the extension
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/patient_http/sidekiq/web_ui.rb', line 32 def registered(app) # GET route for the main PatientHttp dashboard page app.get "/patient-http" do stats = PatientHttp::Sidekiq::Stats.new # Get process-level inflight and capacity data from TaskMonitor processes = PatientHttp::Sidekiq::TaskMonitor.inflight_counts_by_process # Get totals and calculate derived values totals = stats.get_totals total_requests = totals["requests"] || 0 avg_duration = (total_requests > 0) ? ((totals["duration"] || 0).to_f / total_requests).round(3) : 0.0 # Capacity metrics from TaskMonitor max_capacity = processes.values.sum { |data| data[:max_capacity] } current_inflight = processes.values.sum { |data| data[:inflight] } utilization = (max_capacity > 0) ? (current_inflight.to_f / max_capacity * 100).round(1) : 0 erb(PatientHttp::Sidekiq::WebUI.template, locals: { totals: totals, total_requests: total_requests, avg_duration: avg_duration, max_capacity: max_capacity, current_inflight: current_inflight, utilization: utilization, processes: processes }) end # POST route for clearing statistics app.post "/patient-http/clear" do PatientHttp::Sidekiq::Stats.new.reset! redirect "#{root_path}patient-http" end end |
.template ⇒ Object
Sidekiq resolves symbol view names to different file names depending on the version (*.erb before 8.1, *.html.erb from 8.1 on), so the template is rendered from a string instead.
27 28 29 |
# File 'lib/patient_http/sidekiq/web_ui.rb', line 27 def template @template ||= File.read(File.join(VIEWS, "patient_http.html.erb")) end |