class JoobQ::Metrics

Defined in:

joobq/metrics.cr

Instance Method Summary

Instance Method Detail

def add_job_execution_time(execution_time : Time::Span) #

[View source]
def add_job_wait_time(wait_time : Time::Span) #

[View source]
def average_jobs_in_flight : Float64 #

Calculate the average number of jobs in flight in the queue This is used to determine the average number of jobs that are being processed concurrently in the queue


[View source]
def busy : Atomic(Int64) #

[View source]
def completed : Atomic(Int64) #

[View source]
def dead : Atomic(Int64) #

[View source]
def decrement_busy #

[View source]
def elapsed_time : Time::Span #

Calculate elapsed time since the start of the queue This is used to calculate rates per second for metrics


[View source]
def error_rate_trend : Float64 #

Calculate the error rate trend for the queue This is used to determine the trend of errors in the queue over time The error rate trend is calculated as the percentage of retried jobs compared to the total number of attempted jobs


[View source]
def errors_per_second : Float64 #

Calculate the rate at which jobs are being enqueued per second for the queue This is used to calculate the rate at which the queue is being reduced in size


[View source]
def failed_job_rate : Float64 #

Calculate the rate of failed jobs in the queue This is used to determine the rate of jobs that have failed to be processed in the queue The failed job rate is calculated as the percentage of dead jobs compared to the total number of processed jobs


[View source]
def increment_busy #

[View source]
def increment_completed #

Provides thread-safe methods to update metrics


[View source]
def increment_dead #

[View source]
def increment_retried #

[View source]
def job_execution_time : Float64 #

[View source]
def job_wait_time : Float64 #

[View source]
def jobs_completed_per_second : Float64 #

Metric calculations


[View source]
def last_queue_size : Int64 #

[View source]
def last_queue_size=(last_queue_size : Int64) #

[View source]
def last_queue_time : Time::Span #

[View source]
def last_queue_time=(last_queue_time : Time::Span) #

[View source]
def queue_reduction_rate(current_queue_size : Int64) : Float64 #

Calculate the rate at which the queue is being reduced in size per second

Understanding the queue_reduction_rate Method

Definition: The rate at which the queue size is decreasing over time. Purpose: To measure how quickly jobs are being processed and removed from the queue.

Positive Reduction Rate: Indicates the queue size is decreasing. Negative Reduction Rate: Indicates the queue size is increasing.


[View source]
def retried : Atomic(Int64) #

[View source]
def start_time : Time::Span #

[View source]
def start_time=(start_time : Time::Span) #

[View source]
def total_job_execution_time : Time::Span #

[View source]
def total_job_execution_time=(total_job_execution_time : Time::Span) #

[View source]
def total_job_wait_time : Time::Span #

[View source]
def total_job_wait_time=(total_job_wait_time : Time::Span) #

[View source]
def worker_utilization(total_workers : Int32) : Float64 #

Calculate the utilization of workers in the queue based on the total time spent processing jobs TWorker Utilization measures how effectively your workers are being used over time. In your system, it's calculated as

Total Job Execution Time: The cumulative time all workers have spent executing jobs. Total Worker Time: The total time all workers have been available to process jobs

E.g. A worker utilization of 0.14% indicates that your workers are idle 99.86% of the time.

Possible Reasons for Low Worker Utilization


[View source]