Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #1 from rapportive-oss/review.fix-async

Fix time measurement for async
  • Loading branch information...
commit 6b1853877fd18989d038fd1aae3be041d7888ba8 2 parents e0978c6 + 864f595
Sam Stokes samstokes authored

Showing 2 changed files with 6 additions and 6 deletions. Show diff stats Hide diff stats

  1. +5 5 lib/rack/informant.rb
  2. +1 1  rack-informant.gemspec
10 lib/rack/informant.rb
@@ -30,13 +30,13 @@ def initialize(app, &block)
30 30 end
31 31
32 32 def call(env)
33   - @start = Time.now
  33 + start = Time.now
34 34
35 35 if original_callback = env['async.callback']
36 36 env['async.callback'] = proc do |response|
37 37 status, headers, body = response
38 38
39   - inform!(env, status, headers, body)
  39 + inform!(env, start, status, headers, body)
40 40
41 41 original_callback.call(response)
42 42 end
@@ -49,7 +49,7 @@ def call(env)
49 49 return [status, headers, body] if status == -1 # alternative async API
50 50
51 51 # if we got *this* far, @app.call is definitely synchronous
52   - inform!(env, status, headers, body)
  52 + inform!(env, start, status, headers, body)
53 53
54 54 return [status, headers, body]
55 55 end
@@ -59,8 +59,8 @@ def call(env)
59 59 end
60 60
61 61 private
62   - def inform!(env, status, headers, body)
63   - runtime = Time.now - @start
  62 + def inform!(env, start, status, headers, body)
  63 + runtime = Time.now - start
64 64
65 65 event = {
66 66 method: env['REQUEST_METHOD'],
2  rack-informant.gemspec
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
2 2 s.name = 'rack-informant'
3 3 s.authors = ['Rapportive Inc']
4 4 s.email = 'supportive@rapportive.com'
5   - s.version = '1.0.0'
  5 + s.version = '1.1.0'
6 6 s.summary = %q{Reporting middleware.}
7 7 s.description = "Middleware that reports all requests to an interested party (e.g. for analytics)."
8 8 s.homepage = "https://github.com/rapportive-oss/rack-informant"

0 comments on commit 6b18538

Please sign in to comment.
Something went wrong with that request. Please try again.