From a7db24c51c1972735b392fd8311fe105f8327f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nordstrand?= Date: Fri, 30 Aug 2024 15:22:26 +0200 Subject: [PATCH] Use a notification instead of StatsdDdog directly --- lib/request_queue_time/middleware.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/request_queue_time/middleware.rb b/lib/request_queue_time/middleware.rb index d631c19..0c69774 100644 --- a/lib/request_queue_time/middleware.rb +++ b/lib/request_queue_time/middleware.rb @@ -7,17 +7,19 @@ def initialize(app) @app = app end - def call(env) + def call(env, &statsd_block) metrics = Metrics.new(env) AutoScalingMetrics::Reporter.start if ENV["ECS_SETUP"] unless metrics.ignore? tags = ["request_method:#{env["REQUEST_METHOD"]}"] - if Object.const_defined?(:StatsdDdog) - StatsdDdog.timing("rails.request.queue_time", metrics.queue_time, tags:) - StatsdDdog.timing("rails.request.queue_time.network_time", metrics.network_time, tags:) - end + + ActiveSupport::Notifications.instrument("request_queue_time.timings", extra: { + tags: tags, + queue_time: metrics.queue_time, + network_time: metrics.network_time + }) env["request_queue_time"] = metrics.queue_time env["request_network_time"] = metrics.network_time