module Sidekiq::Metrics::Query

Defined in:

sidekiq/metrics/query.cr

Class Method Summary

Class Method Detail

def self.aggregate(data : Hash(Int64, Hash(String, String))) : NamedTuple(success: Int64, failure: Int64, total_ms: Float64) #

Aggregate metrics data for display Returns totals for success, failure, total_ms across all timestamps


[View source]
def self.fetch(job_class : String, start_time : Time, end_time : Time) : Hash(Int64, Hash(String, String)) #

Fetch metrics for a specific job class within a time range Returns a hash of timestamp => metrics data Results are cached for 60 seconds to reduce Redis load


[View source]
def self.job_classes : Array(String) #

Get all job classes that have metrics data


[View source]
def self.record(job_class : String, duration_ms : Float64, success : Bool, timestamp : Int64 = Metrics.minute_timestamp) #

Record job execution metrics to Redis

  • job_class: The worker class name (e.g., "HardWorker")
  • duration_ms: Execution time in milliseconds
  • success: Whether the job completed without raising an exception
  • timestamp: Unix timestamp truncated to minute (defaults to current time)

[View source]