Skip to content

Commit

Permalink
Use a notification instead of StatsdDdog directly
Browse files Browse the repository at this point in the history
  • Loading branch information
bjonord committed Aug 30, 2024
1 parent bab68cd commit a7db24c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/request_queue_time/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a7db24c

Please sign in to comment.