mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-13 15:58:50 +00:00
Merge commit '2f98134ac69ee840095c9d8389e4b2fff72f20c1' into glitch-soc/merge-upstream
This commit is contained in:
26
lib/mastodon/middleware/prometheus_queue_time.rb
Normal file
26
lib/mastodon/middleware/prometheus_queue_time.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Mastodon
|
||||
module Middleware
|
||||
class PrometheusQueueTime < ::PrometheusExporter::Middleware
|
||||
# Overwrite to only collect the queue time metric
|
||||
def call(env)
|
||||
queue_time = measure_queue_time(env)
|
||||
|
||||
result = @app.call(env)
|
||||
|
||||
result
|
||||
ensure
|
||||
obj = {
|
||||
type: 'web',
|
||||
queue_time: queue_time,
|
||||
default_labels: default_labels(env, result),
|
||||
}
|
||||
labels = custom_labels(env)
|
||||
obj = obj.merge(custom_labels: labels) if labels
|
||||
|
||||
@client.send_json(obj)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user