librato-rack 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +1 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +3 -0
- data/README.md +15 -3
- data/lib/librato/rack.rb +2 -0
- data/lib/librato/rack/version.rb +1 -1
- data/test/apps/queue_wait.ru +4 -1
- data/test/integration/queue_wait_test.rb +19 -0
- metadata +42 -62
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d291d01af87d4bef2ce62492b0d44487112626b6
|
4
|
+
data.tar.gz: dfe86fb5950bfa428bb153a471f14d5bf2b9fee2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8fc08bb0ce4c5a06864cf1f2c43818a4e9485c0adebdafde1e5ab7a427c1b38b620aca87af7115d671936731ad346ac8a17d28bf9678b488d4ec655a13afc5fb
|
7
|
+
data.tar.gz: f87fb8ebb490fbe3e2ecb1ca6db297b07841fafbc66ee2e53b52ccc3b1e07a0825ab8a183a58cda4e19b9501ee2e6399963b43d79261dd257f3aebc50360ee40
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
E�ݕ�%�+�g�>����ނs}�>��P�g^9�(�RHvj��4�>��OI�����iS�u�>:{�L�Q���;�_nv��[�y__�С�'0�i�����
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -3,10 +3,20 @@ librato-rack
|
|
3
3
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/librato-rack.png)](http://badge.fury.io/rb/librato-rack) [![Build Status](https://secure.travis-ci.org/librato/librato-rack.png?branch=master)](http://travis-ci.org/librato/librato-rack) [![Code Climate](https://codeclimate.com/github/librato/librato-rack.png)](https://codeclimate.com/github/librato/librato-rack)
|
5
5
|
|
6
|
+
---
|
7
|
+
|
8
|
+
**NOTE:** Starting with version 2.0.0 librato-rack requires a Librato account that [supports tagged metrics](https://www.librato.com/docs/kb/faq/account_questions/tags_or_sources/). If your Librato account doesn't yet support tagged metrics please use the [1.x.x version](https://rubygems.org/gems/librato-rack/versions/1.1.0).
|
9
|
+
|
10
|
+
---
|
11
|
+
|
6
12
|
`librato-rack` provides rack middleware which will report key statistics for your rack applications to [Librato Metrics](https://metrics.librato.com/). It will also allow you to easily track your own custom metrics. Metrics are delivered asynchronously behind the scenes so they won't affect performance of your requests.
|
7
13
|
|
8
14
|
Currently Ruby 1.9.2+ is required.
|
9
15
|
|
16
|
+
## Upgrading
|
17
|
+
|
18
|
+
Upgrading from version 1.x to 2.x introduces breaking changes for legacy sources. Please contact [support@librato.com](mailto:support@librato.com) to migrate an existing Librato account.
|
19
|
+
|
10
20
|
## Quick Start
|
11
21
|
|
12
22
|
Install `librato-rack` as middleware in your application:
|
@@ -159,8 +169,10 @@ Note that `increment` is primarily used for tracking the rate of occurrence of s
|
|
159
169
|
|
160
170
|
Especially with custom per-measurement tags you may want the opposite behavior - reporting a measurement only during intervals where `increment` was called on the metric:
|
161
171
|
|
162
|
-
|
163
|
-
|
172
|
+
```ruby
|
173
|
+
# report a value for 'user.uploaded_file' only during non-zero intervals
|
174
|
+
Librato.increment 'user.uploaded_file', tags: { user_id: user.id, bucket: bucket.name }, sporadic: true
|
175
|
+
```
|
164
176
|
|
165
177
|
#### measure
|
166
178
|
|
@@ -256,4 +268,4 @@ If you are debugging setup locally you can set `flush_interval` to something sho
|
|
256
268
|
|
257
269
|
## Copyright
|
258
270
|
|
259
|
-
Copyright (c) 2013-
|
271
|
+
Copyright (c) 2013-2017 [Librato Inc.](http://librato.com) See LICENSE for details.
|
data/lib/librato/rack.rb
CHANGED
@@ -152,9 +152,11 @@ module Librato
|
|
152
152
|
case queue_start.length
|
153
153
|
when 16 # microseconds
|
154
154
|
wait = ((Time.now.to_f * 1000000).to_i - queue_start.to_i) / 1000.0
|
155
|
+
wait = 0 if wait < 0 # make up for potential time drift between the routing server and the application server
|
155
156
|
tracker.timing 'rack.request.queue.time', wait, percentile: 95
|
156
157
|
when 13 # milliseconds
|
157
158
|
wait = (Time.now.to_f * 1000).to_i - queue_start.to_i
|
159
|
+
wait = 0 if wait < 0 # make up for potential time drift between the routing server and the application server
|
158
160
|
tracker.timing 'rack.request.queue.time', wait, percentile: 95
|
159
161
|
end
|
160
162
|
end
|
data/lib/librato/rack/version.rb
CHANGED
data/test/apps/queue_wait.ru
CHANGED
@@ -26,6 +26,9 @@ class QueueWait
|
|
26
26
|
when '/with_period'
|
27
27
|
env['HTTP_X_REQUEST_START'] = "%10.3f" % Time.now
|
28
28
|
sleep 0.025
|
29
|
+
when '/with_time_drift'
|
30
|
+
env['HTTP_X_REQUEST_START'] = ((Time.now.to_f * 1000).to_i + 10).to_s # 10s in the future
|
31
|
+
sleep 0.005
|
29
32
|
end
|
30
33
|
@app.call(env)
|
31
34
|
end
|
@@ -38,4 +41,4 @@ def application(env)
|
|
38
41
|
[200, {"Content-Type" => 'text/html'}, ["Hello!"]]
|
39
42
|
end
|
40
43
|
|
41
|
-
run method(:application)
|
44
|
+
run method(:application)
|
@@ -62,6 +62,25 @@ class QueueWaitTest < Minitest::Test
|
|
62
62
|
assert_in_delta 25, aggregate["rack.request.queue.time"][:sum], delta
|
63
63
|
end
|
64
64
|
|
65
|
+
def test_with_period
|
66
|
+
get '/with_period'
|
67
|
+
|
68
|
+
# give jruby a bit more time since it can be slow
|
69
|
+
delta = defined?(JRUBY_VERSION) ? 10 : 6
|
70
|
+
assert_equal 1, aggregate["rack.request.queue.time"][:count],
|
71
|
+
'should track total queue time'
|
72
|
+
assert_in_delta 25, aggregate["rack.request.queue.time"][:sum], delta
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_with_time_drift
|
76
|
+
get '/with_time_drift'
|
77
|
+
|
78
|
+
# puts "milli: #{aggregate["rack.request.queue.time"].inspect}"
|
79
|
+
assert_equal 1, aggregate["rack.request.queue.time"][:count],
|
80
|
+
'should track total queue time'
|
81
|
+
assert_in_delta 0, aggregate["rack.request.queue.time"][:sum], 4
|
82
|
+
end
|
83
|
+
|
65
84
|
private
|
66
85
|
|
67
86
|
def aggregate
|
metadata
CHANGED
@@ -1,89 +1,76 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: librato-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Matt Sanders
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain:
|
12
|
-
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
N3FHc3B5cFQwVWgvdy9Cb2RFY0d1QWFaWkZsa1U5dm90dFRlNndXTm5NNmhm
|
35
|
-
UkV4aVNJc3Irb1ZlCnM4czgzT2JzaGp1U3pqT3FTNTZJQnRObFBFTCtENmdo
|
36
|
-
alpaTFAzbFM2bDlwNzBQY3BjbCtJY0U0dmVxWm1tS0MKc0dlcGdSY2xDNlVi
|
37
|
-
WmgreVEzYWxYVmdoTTJxc29uQXdJL3JUTm1GSk45a1FuNm5QOStmMVVmL3Fa
|
38
|
-
Rk5jam40TAo5Ymc9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
|
39
|
-
date: 2017-01-25 00:00:00.000000000 Z
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDLjCCAhagAwIBAgIBADANBgkqhkiG9w0BAQUFADA9MQ0wCwYDVQQDDARydWJ5
|
14
|
+
MRcwFQYKCZImiZPyLGQBGRYHbGlicmF0bzETMBEGC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3alXVghM2qsonAwI/rTNmFJN9kQn6nP9+f1Uf/qZFNcjn4L
|
30
|
+
9bg=
|
31
|
+
-----END CERTIFICATE-----
|
32
|
+
date: 2017-02-21 00:00:00.000000000 Z
|
40
33
|
dependencies:
|
41
34
|
- !ruby/object:Gem::Dependency
|
42
35
|
name: librato-metrics
|
43
36
|
requirement: !ruby/object:Gem::Requirement
|
44
|
-
none: false
|
45
37
|
requirements:
|
46
|
-
- - ~>
|
38
|
+
- - "~>"
|
47
39
|
- !ruby/object:Gem::Version
|
48
40
|
version: 2.1.0
|
49
41
|
type: :runtime
|
50
42
|
prerelease: false
|
51
43
|
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
none: false
|
53
44
|
requirements:
|
54
|
-
- - ~>
|
45
|
+
- - "~>"
|
55
46
|
- !ruby/object:Gem::Version
|
56
47
|
version: 2.1.0
|
57
48
|
- !ruby/object:Gem::Dependency
|
58
49
|
name: hetchy
|
59
50
|
requirement: !ruby/object:Gem::Requirement
|
60
|
-
none: false
|
61
51
|
requirements:
|
62
|
-
- - ~>
|
52
|
+
- - "~>"
|
63
53
|
- !ruby/object:Gem::Version
|
64
54
|
version: '1.0'
|
65
55
|
type: :runtime
|
66
56
|
prerelease: false
|
67
57
|
version_requirements: !ruby/object:Gem::Requirement
|
68
|
-
none: false
|
69
58
|
requirements:
|
70
|
-
- - ~>
|
59
|
+
- - "~>"
|
71
60
|
- !ruby/object:Gem::Version
|
72
61
|
version: '1.0'
|
73
62
|
- !ruby/object:Gem::Dependency
|
74
63
|
name: minitest
|
75
64
|
requirement: !ruby/object:Gem::Requirement
|
76
|
-
none: false
|
77
65
|
requirements:
|
78
|
-
- -
|
66
|
+
- - ">="
|
79
67
|
- !ruby/object:Gem::Version
|
80
68
|
version: '0'
|
81
69
|
type: :development
|
82
70
|
prerelease: false
|
83
71
|
version_requirements: !ruby/object:Gem::Requirement
|
84
|
-
none: false
|
85
72
|
requirements:
|
86
|
-
- -
|
73
|
+
- - ">="
|
87
74
|
- !ruby/object:Gem::Version
|
88
75
|
version: '0'
|
89
76
|
description: Rack middleware to report key app statistics and custom instrumentation
|
@@ -95,25 +82,25 @@ executables: []
|
|
95
82
|
extensions: []
|
96
83
|
extra_rdoc_files: []
|
97
84
|
files:
|
85
|
+
- CHANGELOG.md
|
86
|
+
- LICENSE
|
87
|
+
- README.md
|
88
|
+
- Rakefile
|
89
|
+
- lib/librato-rack.rb
|
90
|
+
- lib/librato/collector.rb
|
98
91
|
- lib/librato/collector/aggregator.rb
|
99
92
|
- lib/librato/collector/counter_cache.rb
|
100
93
|
- lib/librato/collector/exceptions.rb
|
101
94
|
- lib/librato/collector/group.rb
|
102
|
-
- lib/librato/
|
103
|
-
- lib/librato/rack/configuration/suites.rb
|
95
|
+
- lib/librato/rack.rb
|
104
96
|
- lib/librato/rack/configuration.rb
|
97
|
+
- lib/librato/rack/configuration/suites.rb
|
105
98
|
- lib/librato/rack/errors.rb
|
106
99
|
- lib/librato/rack/logger.rb
|
107
100
|
- lib/librato/rack/tracker.rb
|
108
101
|
- lib/librato/rack/validating_queue.rb
|
109
102
|
- lib/librato/rack/version.rb
|
110
103
|
- lib/librato/rack/worker.rb
|
111
|
-
- lib/librato/rack.rb
|
112
|
-
- lib/librato-rack.rb
|
113
|
-
- LICENSE
|
114
|
-
- Rakefile
|
115
|
-
- README.md
|
116
|
-
- CHANGELOG.md
|
117
104
|
- test/apps/basic.ru
|
118
105
|
- test/apps/custom.ru
|
119
106
|
- test/apps/custom_suites.ru
|
@@ -140,33 +127,26 @@ files:
|
|
140
127
|
homepage: https://github.com/librato/librato-rack
|
141
128
|
licenses:
|
142
129
|
- BSD-3-Clause
|
130
|
+
metadata: {}
|
143
131
|
post_install_message:
|
144
132
|
rdoc_options: []
|
145
133
|
require_paths:
|
146
134
|
- lib
|
147
135
|
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
-
none: false
|
149
136
|
requirements:
|
150
|
-
- -
|
137
|
+
- - ">="
|
151
138
|
- !ruby/object:Gem::Version
|
152
139
|
version: '0'
|
153
|
-
segments:
|
154
|
-
- 0
|
155
|
-
hash: 2556710528396302648
|
156
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
-
none: false
|
158
141
|
requirements:
|
159
|
-
- -
|
142
|
+
- - ">="
|
160
143
|
- !ruby/object:Gem::Version
|
161
144
|
version: '0'
|
162
|
-
segments:
|
163
|
-
- 0
|
164
|
-
hash: 2556710528396302648
|
165
145
|
requirements: []
|
166
146
|
rubyforge_project:
|
167
|
-
rubygems_version:
|
147
|
+
rubygems_version: 2.2.2
|
168
148
|
signing_key:
|
169
|
-
specification_version:
|
149
|
+
specification_version: 4
|
170
150
|
summary: Use Librato Metrics with your rack application
|
171
151
|
test_files:
|
172
152
|
- test/apps/basic.ru
|
metadata.gz.sig
CHANGED
Binary file
|