Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Timing was broken for async endpoints, fix it...

There's only one Rack::Informant instance per app (not per request!), so
for async endpoints, @start would get overwritten by each subsequent
request.  An outstanding request would therefore appear to have started
whenever the most recent request came in, rather than when it actually
started, and thus be reported as quicker than it was.

Fix by using a local variable in #call (which *is* per-request) rather
than an instance variable.

Thanks @ept for pointing this out.
  • Loading branch information...
commit 961d24255146136317c3501e2681dda09a0a5648 1 parent e0978c6
@samstokes samstokes authored
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/rack/informant.rb
10 lib/rack/informant.rb
@@ -30,13 +30,13 @@ def initialize(app, &block)
def call(env)
- @start =
+ start =
if original_callback = env['async.callback']
env['async.callback'] = proc do |response|
status, headers, body = response
- inform!(env, status, headers, body)
+ inform!(env, start, status, headers, body)
@@ -49,7 +49,7 @@ def call(env)
return [status, headers, body] if status == -1 # alternative async API
# if we got *this* far, is definitely synchronous
- inform!(env, status, headers, body)
+ inform!(env, start, status, headers, body)
return [status, headers, body]
@@ -59,8 +59,8 @@ def call(env)
- def inform!(env, status, headers, body)
- runtime = - @start
+ def inform!(env, start, status, headers, body)
+ runtime = - start
event = {
method: env['REQUEST_METHOD'],
Please sign in to comment.
Something went wrong with that request. Please try again.