librato-metrics 2.1.0.beta → 2.1.0
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 +0 -0
- data/.travis.yml +4 -4
- data/CHANGELOG.md +4 -1
- data/README.md +44 -2
- data/certs/librato-public.pem +16 -16
- data/lib/librato/metrics/middleware/expects_status.rb +18 -9
- data/lib/librato/metrics/version.rb +1 -1
- data/librato-metrics.gemspec +1 -1
- data/spec/integration/metrics_spec.rb +2 -2
- metadata +31 -29
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
## Changelog
|
2
2
|
|
3
|
-
### Version 2.1.0
|
3
|
+
### Version 2.1.0
|
4
4
|
* Add support for tagged measurements (#121)
|
5
5
|
|
6
|
+
### Version 2.0.2
|
7
|
+
* Filter sensitive headers in exception output (#130, Yannick Schutz)
|
8
|
+
|
6
9
|
### Version 2.0.1
|
7
10
|
* Fix SmartJSON delegation bug for ruby 2.3.1 (#123)
|
8
11
|
|
data/README.md
CHANGED
@@ -184,6 +184,31 @@ Both options are driven by the addition of measurements. *If you are adding meas
|
|
184
184
|
|
185
185
|
If your goal is to collect metrics every _x_ seconds and submit them, [check out this code example](https://github.com/librato/librato-metrics/blob/master/examples/submit_every.rb).
|
186
186
|
|
187
|
+
## Submitting tagged measurements
|
188
|
+
|
189
|
+
Librato Metrics supports tagged measurements that are associated with a metric, one or more tag pairs, and a point in time.
|
190
|
+
|
191
|
+
**Tags** are a set of name=value tag pairs that describe the particular data stream. Tags behave as extra dimensions that data streams can be filtered and aggregated along.
|
192
|
+
|
193
|
+
### Top-Level Tags
|
194
|
+
|
195
|
+
You can initialize `Queue` and/or `Aggregator` with top-level tags that will be applied to every measurement:
|
196
|
+
|
197
|
+
```ruby
|
198
|
+
queue = Librato::Metrics::Queue.new(tags: { service: 'auth', environment: 'prod', host: 'auth-prod-1' })
|
199
|
+
queue.add my_metric: 10
|
200
|
+
```
|
201
|
+
|
202
|
+
### Per-Measurement Tags
|
203
|
+
|
204
|
+
Optionally, you can submit per-measurement tags by passing a tags Hash when adding measurements:
|
205
|
+
|
206
|
+
```ruby
|
207
|
+
queue.add my_other_metric: { value: 25, tags: { db: 'rr1' } }
|
208
|
+
```
|
209
|
+
|
210
|
+
For more information, visit the [API documentation](https://www.librato.com/docs/api/#create-a-measurement).
|
211
|
+
|
187
212
|
## Querying Metrics
|
188
213
|
|
189
214
|
Get name and properties for all metrics you have in the system:
|
@@ -216,9 +241,26 @@ Get the 5 minute moving average for `temperature` for the last hour, assuming te
|
|
216
241
|
|
217
242
|
data = Librato::Metrics.get_composite 'moving_average(mean(series("temperature", "*"), {size: "5"}))', start_time: Time.now.to_i - 60*60, resolution: 300
|
218
243
|
|
219
|
-
There are many more options supported for querying, take a look at the
|
244
|
+
There are many more options supported for querying, take a look at the
|
220
245
|
[REST API docs](https://www.librato.com/docs/api/#retrieve-metrics) or the individual method documentation for more details.
|
221
246
|
|
247
|
+
## Retrieving tagged measurements (beta)
|
248
|
+
|
249
|
+
Get the series for `exceptions` in **production** grouped by **sum** within the **last hour**:
|
250
|
+
|
251
|
+
```ruby
|
252
|
+
query = {
|
253
|
+
resolution: 1,
|
254
|
+
duration: 3600,
|
255
|
+
group_by: "environment",
|
256
|
+
group_by_function: "sum",
|
257
|
+
tags_search: "environment=prod*"
|
258
|
+
}
|
259
|
+
Librato::Metrics.get_series :exceptions, query
|
260
|
+
```
|
261
|
+
|
262
|
+
For more information, visit the [API documentation](https://www.librato.com/docs/api/#retrieve-a-measurement).
|
263
|
+
|
222
264
|
## Setting Metric Properties
|
223
265
|
|
224
266
|
Setting custom [properties](https://www.librato.com/docs/api/#metric-attributes) on your metrics is easy:
|
@@ -292,4 +334,4 @@ We also maintain a set of [examples of common uses](https://github.com/librato/l
|
|
292
334
|
|
293
335
|
## Copyright
|
294
336
|
|
295
|
-
Copyright (c) 2011-
|
337
|
+
Copyright (c) 2011-2016 [Librato Inc.](http://librato.com) See LICENSE for details.
|
data/certs/librato-public.pem
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
|
-
|
2
|
+
MIIDLjCCAhagAwIBAgIBADANBgkqhkiG9w0BAQUFADA9MQ0wCwYDVQQDDARydWJ5
|
3
3
|
MRcwFQYKCZImiZPyLGQBGRYHbGlicmF0bzETMBEGCgmSJomT8ixkARkWA2NvbTAe
|
4
|
-
|
4
|
+
Fw0xNzAxMTExODI3MDdaFw0xODAxMTExODI3MDdaMD0xDTALBgNVBAMMBHJ1Ynkx
|
5
5
|
FzAVBgoJkiaJk/IsZAEZFgdsaWJyYXRvMRMwEQYKCZImiZPyLGQBGRYDY29tMIIB
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
+
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
6
|
+
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA58LirwsWnKL1uuClQ0uwA1XL
|
7
|
+
GpxDuFzSosipiPkzZY3hiHazC8SHDREZQXlm7ITX/o+dueNoB7dt0BR3RPVipH7V
|
8
|
+
7cvbCUaZNjEXR5Lal6PsmUsbMTrddkvj3e7flmJv+kMj+teeJ7MDeJTU5wXXV9pD
|
9
|
+
ThiCDILJMF5CdP8Jru4rSBOP6RmmzYU+0cN5+5pt9xqrycA+Poo2ZuoUMCMsSBvl
|
10
|
+
PimM3PPvoWTuE41GTn/bLoOVoXQmdwZIbwUSVH8rCDjZSlttOst+xrBw4KG0dYUp
|
11
|
+
2UvEe8iCyqEMQ8fEZ7EXuP2WMVICutFbz8Pt4hIMq+OTnDX+mIfma7GvPaKAFwID
|
12
|
+
AQABozkwNzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQBSxu9Jj4VTrXTpLujPwk9Kzwp
|
13
|
+
2jALBgNVHQ8EBAMCBLAwDQYJKoZIhvcNAQEFBQADggEBACvNsw1pGv72xp3LiDlZ
|
14
|
+
0tphNP/85RcYyJMklslG3tIYblyo71xHW1UbK5ArUK6k0BN43MuDn3pqLJQttVmi
|
15
|
+
bUdA3yYi13GeSrrAMlr4nH8Yt/Bn/XpZGliouJUBwh1BjG6dSj1iuR4/9pt9/LtO
|
16
|
+
QTdIc+07qGspypT0Uh/w/BodEcGuAaZZFlkU9vottTe6wWNnM6hfRExiSIsr+oVe
|
17
|
+
s8s83ObshjuSzjOqS56IBtNlPEL+D6ghjZZLP3lS6l9p70Pcpcl+IcE4veqZmmKC
|
18
|
+
sGepgRclC6UbZh+yQ3alXVghM2qsonAwI/rTNmFJN9kQn6nP9+f1Uf/qZFNcjn4L
|
19
|
+
9bg=
|
20
20
|
-----END CERTIFICATE-----
|
@@ -5,25 +5,34 @@ module Librato
|
|
5
5
|
class ExpectsStatus < Faraday::Response::Middleware
|
6
6
|
|
7
7
|
def on_complete(env)
|
8
|
-
|
8
|
+
sanitized = sanitize_request(env)
|
9
9
|
case env[:status]
|
10
10
|
when 401
|
11
|
-
raise Unauthorized.new(
|
11
|
+
raise Unauthorized.new(sanitized.to_s, sanitized)
|
12
12
|
when 403
|
13
|
-
raise Forbidden.new(
|
13
|
+
raise Forbidden.new(sanitized.to_s, sanitized)
|
14
14
|
when 404
|
15
|
-
raise NotFound.new(
|
15
|
+
raise NotFound.new(sanitized.to_s, sanitized)
|
16
16
|
when 422
|
17
|
-
raise EntityAlreadyExists.new(
|
17
|
+
raise EntityAlreadyExists.new(sanitized.to_s, sanitized)
|
18
18
|
when 400..499
|
19
|
-
raise ClientError.new(
|
19
|
+
raise ClientError.new(sanitized.to_s, sanitized)
|
20
20
|
when 500..599
|
21
|
-
raise ServerError.new(
|
21
|
+
raise ServerError.new(sanitized.to_s, sanitized)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
def sanitize_request(env)
|
26
|
+
{
|
27
|
+
status: env.status,
|
28
|
+
url: env.url.to_s,
|
29
|
+
user_agent: env.request_headers["User-Agent"],
|
30
|
+
request_body: env[:request_body],
|
31
|
+
response_headers: env.response_headers,
|
32
|
+
response_body: env.body
|
33
|
+
}
|
34
|
+
end
|
25
35
|
end
|
26
|
-
|
27
36
|
end
|
28
37
|
end
|
29
|
-
end
|
38
|
+
end
|
data/librato-metrics.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.description = "An easy to use ruby wrapper for Librato's Metrics API"
|
18
18
|
|
19
19
|
s.authors = ["Matt Sanders"]
|
20
|
-
s.email = 'matt@librato.com'
|
20
|
+
s.email = ['matt@librato.com', 'ruby@librato.com']
|
21
21
|
s.homepage = 'https://github.com/librato/librato-metrics'
|
22
22
|
|
23
23
|
s.require_paths = %w[lib]
|
@@ -220,7 +220,7 @@ module Librato
|
|
220
220
|
Metrics.submit foo: {type: :counter, value: 12}
|
221
221
|
expect {
|
222
222
|
Metrics.submit foo: 15 # submitting as gauge
|
223
|
-
}.to raise_error
|
223
|
+
}.to raise_error(Librato::Metrics::ClientError)
|
224
224
|
expect {
|
225
225
|
Metrics.submit foo: {type: :counter, value: 17}
|
226
226
|
}.not_to raise_error
|
@@ -273,7 +273,7 @@ module Librato
|
|
273
273
|
attributes: {
|
274
274
|
display_max: 1000
|
275
275
|
}
|
276
|
-
}.to raise_error
|
276
|
+
}.to raise_error(Librato::Metrics::ClientError)
|
277
277
|
end
|
278
278
|
end
|
279
279
|
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: librato-metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.0
|
5
|
-
prerelease:
|
4
|
+
version: 2.1.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Matt Sanders
|
@@ -11,32 +11,32 @@ bindir: bin
|
|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42
|
name: faraday
|
@@ -71,7 +71,9 @@ dependencies:
|
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: 0.2.2
|
73
73
|
description: An easy to use ruby wrapper for Librato's Metrics API
|
74
|
-
email:
|
74
|
+
email:
|
75
|
+
- matt@librato.com
|
76
|
+
- ruby@librato.com
|
75
77
|
executables: []
|
76
78
|
extensions: []
|
77
79
|
extra_rdoc_files:
|
@@ -141,9 +143,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
144
|
none: false
|
143
145
|
requirements:
|
144
|
-
- - ! '
|
146
|
+
- - ! '>='
|
145
147
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
148
|
+
version: '0'
|
147
149
|
requirements: []
|
148
150
|
rubyforge_project:
|
149
151
|
rubygems_version: 1.8.23.2
|
metadata.gz.sig
CHANGED
Binary file
|