logjam_agent 0.9.11 → 0.9.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 77f25440ff44dcfb6de3fe9ae686724977b7f40a
4
- data.tar.gz: 8ba9d61faf60974e882b828f1d490be9b0b28eb7
3
+ metadata.gz: 3f89e8dab06c035772e2cb51c4b28d57b03f5909
4
+ data.tar.gz: adddab6424954392a6b5c073cea7a65fefe2ae1a
5
5
  SHA512:
6
- metadata.gz: 9ab6c2a70a61444f2f01b798b16c95da738c176c115b6dfeda4c431fc180de20a0ef0eea6928d13242b0c3de19f559266504faa1baa12b2ddc044c25bd74394d
7
- data.tar.gz: c6936b59faa461bb25dfdb79b4100859fd4d956aa19922466e20a4741abc157f28fa92303059f2dffeb3671b6bd5fc0d74acd0c502a397dc0cc279127bf39306
6
+ metadata.gz: 04cb99940ad5b20d1e65aa94b7c4e29a128c34bc09c3cae44e9d8d1f18af8a4330775c33da4a329635723c5135039176101d5a5cde2e747c854e760e3ffd1960
7
+ data.tar.gz: 7c51e5bc69d9e6564537614e51ebd21391491f50670de373418e00c9ea60340746daf6b1af62c9d65b7c7a85d1419b710188e385c4c0a3de1f816e736551444e
@@ -1,6 +1,7 @@
1
1
  module LogjamAgent
2
2
 
3
3
  class CallerTimeoutExceeded < StandardError; end
4
+ class NegativeWaitTime < StandardError; end
4
5
 
5
6
  module Rack
6
7
  class Logger < ActiveSupport::LogSubscriber
@@ -30,8 +31,9 @@ module LogjamAgent
30
31
  if start_time_header && start_time_header =~ /\At=(\d+)\z/
31
32
  # accuracy?
32
33
  http_start_time = Time.at($1.to_f / 1_000_000.0)
33
- wait_time_ms = (start_time - http_start_time) * 1000
34
- start_time = http_start_time
34
+ if (wait_time_ms = (start_time - http_start_time) * 1000) > 0
35
+ start_time = http_start_time
36
+ end
35
37
  else
36
38
  wait_time_ms = 0.0
37
39
  end
@@ -85,21 +87,25 @@ module LogjamAgent
85
87
  if completed_info = Thread.current.thread_variable_get(:time_bandits_completed_info)
86
88
  _, additions, view_time, _ = completed_info
87
89
  end
88
- request_info = {
89
- :total_time => run_time_ms, :code => status, :view_time => view_time || 0.0, :wait_time => wait_time_ms
90
- }
91
90
  logjam_request = LogjamAgent.request
92
91
 
93
92
  if (allowed_time_ms = env['HTTP_X_LOGJAM_CALLER_TIMEOUT'].to_i) > 0 && (run_time_ms > allowed_time_ms)
94
93
  warn LogjamAgent::CallerTimeoutExceeded.new("exceeded allowed time by #{(run_time_ms.to_i - allowed_time_ms)} ms")
95
94
  end
96
95
 
96
+ if wait_time_ms < 0
97
+ warn LogjamAgent::NegativeWaitTime.new("#{wait_time_ms} ms")
98
+ wait_time_ms = 0.0
99
+ end
100
+
97
101
  message = "Completed #{status} #{::Rack::Utils::HTTP_STATUS_CODES[status]} in %.1fms" % run_time_ms
98
102
  message << " (#{additions.join(' | ')})" unless additions.blank?
99
103
  info message unless logjam_request.ignored?
100
104
 
101
105
  ActiveSupport::LogSubscriber.flush_all!
102
-
106
+ request_info = {
107
+ :total_time => run_time_ms, :code => status, :view_time => view_time || 0.0, :wait_time => wait_time_ms
108
+ }
103
109
  logjam_request.fields.merge!(request_info)
104
110
 
105
111
  env["time_bandits.metrics"] = TimeBandits.metrics
@@ -1,3 +1,3 @@
1
1
  module LogjamAgent
2
- VERSION = "0.9.11"
2
+ VERSION = "0.9.12"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logjam_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.11
4
+ version: 0.9.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Kaes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-08 00:00:00.000000000 Z
11
+ date: 2014-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake