مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-12-01 05:43:04 +00:00
feat(prometheus): add postal_message_queue_latency metric
هذا الالتزام موجود في:
@@ -3,6 +3,8 @@
|
|||||||
module MessageDequeuer
|
module MessageDequeuer
|
||||||
class InitialProcessor < Base
|
class InitialProcessor < Base
|
||||||
|
|
||||||
|
include HasPrometheusMetrics
|
||||||
|
|
||||||
attr_accessor :send_result
|
attr_accessor :send_result
|
||||||
|
|
||||||
def process
|
def process
|
||||||
@@ -10,6 +12,7 @@ module MessageDequeuer
|
|||||||
logger.info "starting message unqueue"
|
logger.info "starting message unqueue"
|
||||||
begin
|
begin
|
||||||
catch_stops do
|
catch_stops do
|
||||||
|
increment_dequeue_metric
|
||||||
check_message_exists
|
check_message_exists
|
||||||
check_message_is_ready
|
check_message_is_ready
|
||||||
find_other_messages_for_batch
|
find_other_messages_for_batch
|
||||||
@@ -28,6 +31,13 @@ module MessageDequeuer
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def increment_dequeue_metric
|
||||||
|
time_in_queue = Time.now.to_f - @queued_message.created_at.to_f
|
||||||
|
log "queue latency is #{time_in_queue}s"
|
||||||
|
observe_prometheus_histogram :postal_message_queue_latency,
|
||||||
|
time_in_queue
|
||||||
|
end
|
||||||
|
|
||||||
def check_message_exists
|
def check_message_exists
|
||||||
return if @queued_message.message
|
return if @queued_message.message
|
||||||
|
|
||||||
|
|||||||
@@ -288,6 +288,9 @@ module Worker
|
|||||||
register_prometheus_histogram :postal_worker_task_runtime,
|
register_prometheus_histogram :postal_worker_task_runtime,
|
||||||
docstring: "The time taken to process tasks",
|
docstring: "The time taken to process tasks",
|
||||||
labels: [:task]
|
labels: [:task]
|
||||||
|
|
||||||
|
register_prometheus_histogram :postal_message_queue_latency,
|
||||||
|
docstring: "The length of time between a message being queued and being dequeued"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم