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