librato-rack 0.4.2 → 0.4.3

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.
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ### Version 0.4.3
2
+ * Update queue wait support to tolerate float-style timestamps
3
+
1
4
  ### Version 0.4.2
2
5
  * Move gem sign code to rake task, fixes bug bundling in some environments
3
6
 
data/lib/librato/rack.rb CHANGED
@@ -103,13 +103,13 @@ module Librato
103
103
  def record_header_metrics(env)
104
104
  queue_start = env['HTTP_X_REQUEST_START'] || env['HTTP_X_QUEUE_START']
105
105
  if queue_start
106
- queue_start = queue_start.to_s.gsub('t=', '').to_i
107
- case queue_start.to_s.length
106
+ queue_start = queue_start.to_s.sub('t=', '').sub('.', '')
107
+ case queue_start.length
108
108
  when 16 # microseconds
109
- wait = ((Time.now.to_f * 1000000).to_i - queue_start) / 1000.0
109
+ wait = ((Time.now.to_f * 1000000).to_i - queue_start.to_i) / 1000.0
110
110
  tracker.timing 'rack.request.queue.time', wait
111
111
  when 13 # milliseconds
112
- wait = (Time.now.to_f * 1000).to_i - queue_start
112
+ wait = (Time.now.to_f * 1000).to_i - queue_start.to_i
113
113
  tracker.timing 'rack.request.queue.time', wait
114
114
  end
115
115
  end
@@ -1,5 +1,5 @@
1
1
  module Librato
2
2
  class Rack
3
- VERSION = "0.4.2"
3
+ VERSION = "0.4.3"
4
4
  end
5
5
  end
@@ -23,6 +23,9 @@ class QueueWait
23
23
  when '/with_t'
24
24
  env['HTTP_X_REQUEST_START'] = "t=#{(Time.now.to_f * 1000000).to_i}".to_s
25
25
  sleep 0.02
26
+ when '/with_period'
27
+ env['HTTP_X_REQUEST_START'] = "%10.3f" % Time.now
28
+ sleep 0.025
26
29
  end
27
30
  @app.call(env)
28
31
  end
@@ -52,6 +52,16 @@ class QueueWaitTest < Minitest::Test
52
52
  assert_in_delta 20, aggregate["rack.request.queue.time"][:sum], 4
53
53
  end
54
54
 
55
+ def test_with_period
56
+ get '/with_period'
57
+
58
+ # give jruby a bit more time since it can be slow
59
+ delta = defined?(JRUBY_VERSION) ? 10 : 4
60
+ assert_equal 1, aggregate["rack.request.queue.time"][:count],
61
+ 'should track total queue time'
62
+ assert_in_delta 25, aggregate["rack.request.queue.time"][:sum], delta
63
+ end
64
+
55
65
  private
56
66
 
57
67
  def aggregate
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librato-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -37,7 +37,7 @@ cert_chain:
37
37
  bktaNmhlblFBRjFDSDk2WmNxY0pIMTc5UzJ0SWlLRE04a2VlUklVT1BDM1dU
38
38
  MGZhb2svMgpnQTJvemRyODUxYy9uQT09Ci0tLS0tRU5EIENFUlRJRklDQVRF
39
39
  LS0tLS0K
40
- date: 2013-08-26 00:00:00.000000000 Z
40
+ date: 2013-09-04 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: librato-metrics
@@ -131,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  segments:
133
133
  - 0
134
- hash: -1690742337957638692
134
+ hash: 2186855998038082473
135
135
  required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  none: false
137
137
  requirements:
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  segments:
142
142
  - 0
143
- hash: -1690742337957638692
143
+ hash: 2186855998038082473
144
144
  requirements: []
145
145
  rubyforge_project:
146
146
  rubygems_version: 1.8.23
metadata.gz.sig CHANGED
@@ -1,3 +1 @@
1
- �L����x]�j���Z�y��� z2xg���C��z���8���j���C��y�g����
2
- ���q2E���)��:Og�� �e0R|��I���x�KΎ��NDAnN��@skb ���?��*�' �I6ᯇ�i���?���˗Sa���`�I3�̝�
3
- �xه���H^���{3�qn�̦�<��ܺ�u@gd��iO\��S�OWt2�roWmYӎ�d{J�~T��� ;�кIzR^� pq�]��
1
+ <�Z��M���Z8B��I��dp*�f[��'��!�l