librato-metrics 1.6.2 → 2.0.0.beta
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 +13 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -0
- data/.rspec +2 -1
- data/.travis.yml +2 -3
- data/CHANGELOG.md +6 -2
- data/Gemfile +3 -2
- data/README.md +33 -33
- data/Rakefile +3 -4
- data/certs/librato-public.pem +18 -18
- data/examples/simple.rb +5 -5
- data/lib/librato/metrics.rb +9 -12
- data/lib/librato/metrics/aggregator.rb +6 -6
- data/lib/librato/metrics/annotator.rb +11 -11
- data/lib/librato/metrics/client.rb +24 -91
- data/lib/librato/metrics/connection.rb +2 -2
- data/lib/librato/metrics/middleware/retry.rb +1 -1
- data/lib/librato/metrics/processor.rb +3 -3
- data/lib/librato/metrics/queue.rb +1 -1
- data/lib/librato/metrics/smart_json.rb +27 -16
- data/lib/librato/metrics/version.rb +1 -1
- data/librato-metrics.gemspec +2 -2
- data/spec/integration/metrics/annotator_spec.rb +73 -73
- data/spec/integration/metrics/middleware/count_requests_spec.rb +8 -8
- data/spec/integration/metrics/queue_spec.rb +28 -28
- data/spec/integration/metrics_spec.rb +137 -137
- data/spec/spec_helper.rb +6 -10
- data/spec/unit/metrics/aggregator_spec.rb +130 -130
- data/spec/unit/metrics/client_spec.rb +37 -37
- data/spec/unit/metrics/connection_spec.rb +30 -30
- data/spec/unit/metrics/queue/autosubmission_spec.rb +25 -25
- data/spec/unit/metrics/queue_spec.rb +178 -179
- data/spec/unit/metrics/smart_json_spec.rb +79 -0
- data/spec/unit/metrics_spec.rb +21 -21
- metadata +48 -42
- metadata.gz.sig +0 -0
- data/spec/integration/deprecated_methods_spec.rb +0 -85
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YTE5NzIwZDkwZjhiMWQ5OWVmNWM1MGViYjViMmYxMzg3NzU0Y2M0Ng==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MmFkM2Q2M2Q4MDNhYTBhZTcyODhkMDRlODg4ZjI1YmIxOTk4Yzk2YQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NGY5Mzk2YjZlNjNlYzYwOWU1YTJhNzJlNDhkOTU5ZjUyZTcxMzBmNDVlODU4
|
10
|
+
MTIxMTI4ZTViMjg1ODY5MjE0OTQ5ODAyMmIzYThmYTQzZTNiMGUzMjU1ZDQ4
|
11
|
+
OTI5ODRhNTM3Y2Y3N2FkODBmMzNiNThiNzE3Mzc4NGRiODkyYzk=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MzdjOGIwODZkNjQyZWU4ODA5YmM4MDYwYTQ5MDhiOTBhY2RhNTE4NjhlNmE4
|
14
|
+
MDc5YTk1ZmY2NzRmYjg0YWFlMjdjYjNlZmExZjY2ZTk5YjliYTA4N2JjMzgx
|
15
|
+
MTBjZmNkMzU3OTlkNDYwYjE1NDA0NDExM2NlOWY5MDNlMDlmMjY=
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
data/.rspec
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
--
|
1
|
+
--color
|
2
|
+
--require spec_helper
|
data/.travis.yml
CHANGED
@@ -2,11 +2,10 @@
|
|
2
2
|
sudo: false
|
3
3
|
|
4
4
|
rvm:
|
5
|
-
# - 1.8.7
|
6
|
-
# - ree
|
7
5
|
- 1.9.3
|
8
6
|
- 2.1.7
|
9
7
|
- 2.2.3
|
8
|
+
- 2.3.0
|
10
9
|
- jruby-19mode
|
11
10
|
# - rbx
|
12
11
|
- ruby-head
|
@@ -22,4 +21,4 @@ branches:
|
|
22
21
|
notifications:
|
23
22
|
email:
|
24
23
|
on_failure: change
|
25
|
-
on_success: never
|
24
|
+
on_success: never
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
## Changelog
|
2
2
|
|
3
|
-
### Version
|
4
|
-
*
|
3
|
+
### Version 2.0.0.beta
|
4
|
+
* Remove support for deprecated methods (#117)
|
5
|
+
* Upgrade rspec from 2.6 to 3.5 (#118)
|
6
|
+
* Remove support for ruby 1.8 (#119)
|
7
|
+
* Remove `MultiJson` runtime dependency (#119)
|
8
|
+
* Relax `Faraday` runtime dependency (#119)
|
5
9
|
|
6
10
|
### Version 1.6.1
|
7
11
|
* Fix bugs with listing sources (#116)
|
data/Gemfile
CHANGED
@@ -17,7 +17,7 @@ end
|
|
17
17
|
|
18
18
|
gemspec
|
19
19
|
|
20
|
-
gem 'rake'
|
20
|
+
gem 'rake'
|
21
21
|
|
22
22
|
# docs
|
23
23
|
gem 'yard'
|
@@ -29,7 +29,8 @@ gem 'pry'
|
|
29
29
|
gem 'quixote'
|
30
30
|
|
31
31
|
group :test do
|
32
|
-
gem 'rspec', '~>
|
32
|
+
gem 'rspec', '~> 3.5.0'
|
33
33
|
gem 'sinatra'
|
34
34
|
gem 'popen4'
|
35
|
+
gem 'multi_json'
|
35
36
|
end
|
data/README.md
CHANGED
@@ -32,11 +32,11 @@ If you are using jruby, you need to ensure [jruby-openssl](https://github.com/jr
|
|
32
32
|
If you are looking for the quickest possible route to getting a data into Metrics, you only need two lines:
|
33
33
|
|
34
34
|
Librato::Metrics.authenticate 'email', 'api_key'
|
35
|
-
Librato::Metrics.submit :
|
35
|
+
Librato::Metrics.submit my_metric: 42, my_other_metric: 1002
|
36
36
|
|
37
37
|
Unspecified metrics will send a *gauge*, but if you need to send a different metric type or include additional properties, simply use a hash:
|
38
38
|
|
39
|
-
Librato::Metrics.submit :
|
39
|
+
Librato::Metrics.submit my_metric: {type: :counter, value: 1002, source: 'myapp'}
|
40
40
|
|
41
41
|
While this is all you need to get started, if you are sending a number of metrics regularly a queue may be easier/more performant so read on...
|
42
42
|
|
@@ -53,7 +53,7 @@ If you are sending very many measurements or sending them very often, it will be
|
|
53
53
|
Queue up a simple gauge metric named `temperature`:
|
54
54
|
|
55
55
|
queue = Librato::Metrics::Queue.new
|
56
|
-
queue.add :
|
56
|
+
queue.add temperature: 32.2
|
57
57
|
|
58
58
|
While symbols are used by convention for metric names, strings will work just as well:
|
59
59
|
|
@@ -64,18 +64,18 @@ If you are tracking measurements over several seconds/minutes, the queue will ha
|
|
64
64
|
If you want to specify a time other than queuing time for the measurement:
|
65
65
|
|
66
66
|
# use a epoch integer
|
67
|
-
queue.add :
|
67
|
+
queue.add humidity: {measure_time: 1336508422, value: 48.2}
|
68
68
|
|
69
69
|
# use a Time object to correct for a 5 second delay
|
70
|
-
queue.add :
|
70
|
+
queue.add humidity: {measure_time: Time.now-5, value: 37.6}
|
71
71
|
|
72
72
|
You can queue multiple metrics at once. Here's a gauge (`load`) and a counter (`visits`):
|
73
73
|
|
74
|
-
queue.add :
|
74
|
+
queue.add load: 2.2, visits: {type: :counter, value: 400}
|
75
75
|
|
76
76
|
Queue up a metric with a specified source:
|
77
77
|
|
78
|
-
queue.add :
|
78
|
+
queue.add cpu: {source: 'app1', value: 92.6}
|
79
79
|
|
80
80
|
A complete [list of metric attributes](http://dev.librato.com/v1/metrics) is available in the [API documentation](http://dev.librato.com/v1).
|
81
81
|
|
@@ -90,23 +90,23 @@ If you are measuring something very frequently e.g. per-request in a web applica
|
|
90
90
|
Aggregate a simple gauge metric named `response_latency`:
|
91
91
|
|
92
92
|
aggregator = Librato::Metrics::Aggregator.new
|
93
|
-
aggregator.add :
|
94
|
-
aggregator.add :
|
95
|
-
aggregator.add :
|
96
|
-
aggregator.add :
|
97
|
-
aggregator.add :
|
93
|
+
aggregator.add response_latency: 85.0
|
94
|
+
aggregator.add response_latency: 100.5
|
95
|
+
aggregator.add response_latency: 150.2
|
96
|
+
aggregator.add response_latency: 90.1
|
97
|
+
aggregator.add response_latency: 92.0
|
98
98
|
|
99
99
|
Which would result in a gauge measurement like:
|
100
100
|
|
101
|
-
{:
|
101
|
+
{name: "response_latency", count: 5, sum: 517.8, min: 85.0, max: 150.2}
|
102
102
|
|
103
103
|
You can specify a source during aggregate construction:
|
104
104
|
|
105
|
-
aggregator = Librato::Metrics::Aggregator.new(:
|
105
|
+
aggregator = Librato::Metrics::Aggregator.new(source: 'foobar')
|
106
106
|
|
107
107
|
You can aggregate multiple metrics at once:
|
108
108
|
|
109
|
-
aggregator.add :
|
109
|
+
aggregator.add app_latency: 35.2, db_latency: 120.7
|
110
110
|
|
111
111
|
Send the currently aggregated metrics to Metrics:
|
112
112
|
|
@@ -124,7 +124,7 @@ The difference between the two is that `Queue` submits each timing measurement i
|
|
124
124
|
|
125
125
|
If you need extra attributes for a `Queue` timing measurement, simply add them on:
|
126
126
|
|
127
|
-
queue.time :my_measurement, :
|
127
|
+
queue.time :my_measurement, source: 'app1' do
|
128
128
|
# do work...
|
129
129
|
end
|
130
130
|
|
@@ -138,9 +138,9 @@ At a minimum each annotation needs to be assigned to a stream and to have a titl
|
|
138
138
|
|
139
139
|
There are a number of optional fields which can make annotations even more powerful:
|
140
140
|
|
141
|
-
Librato::Metrics.annotate :deployments, 'deployed v46', :
|
142
|
-
:
|
143
|
-
:
|
141
|
+
Librato::Metrics.annotate :deployments, 'deployed v46', source: 'frontend',
|
142
|
+
start_time: 1354662596, end_time: 1354662608,
|
143
|
+
description: 'Deployed 6f3bc6e67682: fix lotsa bugs…'
|
144
144
|
|
145
145
|
You can also automatically annotate the start and end time of an action by using `annotate`'s block form:
|
146
146
|
|
@@ -156,7 +156,7 @@ More fine-grained control of annotations is available via the `Annotator` object
|
|
156
156
|
streams = annotator.list
|
157
157
|
|
158
158
|
# fetch a list of events in the last hour from a stream
|
159
|
-
annotator.fetch :deployments, :
|
159
|
+
annotator.fetch :deployments, start_time: (Time.now.to_i-3600)
|
160
160
|
|
161
161
|
# delete an event
|
162
162
|
annotator.delete_event 'deployments', 23
|
@@ -168,15 +168,15 @@ See the documentation of `Annotator` for more details and examples of use.
|
|
168
168
|
Both `Queue` and `Aggregator` support automatically submitting measurements on a given time interval:
|
169
169
|
|
170
170
|
# submit once per minute
|
171
|
-
timed_queue = Librato::Metrics::Queue.new(:
|
171
|
+
timed_queue = Librato::Metrics::Queue.new(autosubmit_interval: 60)
|
172
172
|
|
173
173
|
# submit every 5 minutes
|
174
|
-
timed_aggregator = Librato::Metrics::Aggregator.new(:
|
174
|
+
timed_aggregator = Librato::Metrics::Aggregator.new(autosubmit_interval: 300)
|
175
175
|
|
176
176
|
`Queue` also supports auto-submission based on measurement volume:
|
177
177
|
|
178
178
|
# submit when the 400th measurement is queued
|
179
|
-
volume_queue = Librato::Metrics::Queue.new(:
|
179
|
+
volume_queue = Librato::Metrics::Queue.new(autosubmit_count: 400)
|
180
180
|
|
181
181
|
These options can also be combined for more flexible behavior.
|
182
182
|
|
@@ -192,7 +192,7 @@ Get name and properties for all metrics you have in the system:
|
|
192
192
|
|
193
193
|
Get only metrics whose name includes `time`:
|
194
194
|
|
195
|
-
metrics = Librato::Metrics.metrics :
|
195
|
+
metrics = Librato::Metrics.metrics name: 'time'
|
196
196
|
|
197
197
|
## Querying Metric Data
|
198
198
|
|
@@ -202,19 +202,19 @@ Get attributes for metric `temperature`:
|
|
202
202
|
|
203
203
|
Get the 20 most recent data points for `temperature`:
|
204
204
|
|
205
|
-
data = Librato::Metrics.get_measurements :temperature, :
|
205
|
+
data = Librato::Metrics.get_measurements :temperature, count: 20
|
206
206
|
|
207
207
|
Get the 20 most recent data points for `temperature` from a specific source:
|
208
208
|
|
209
|
-
data = Librato::Metrics.get_measurements :temperature, :
|
209
|
+
data = Librato::Metrics.get_measurements :temperature, count: 20, source: 'app1'
|
210
210
|
|
211
211
|
Get the 20 most recent 15 minute data point rollups for `temperature`:
|
212
212
|
|
213
|
-
data = Librato::Metrics.get_measurements :temperature, :
|
213
|
+
data = Librato::Metrics.get_measurements :temperature, count: 20, resolution: 900
|
214
214
|
|
215
215
|
Get the 5 minute moving average for `temperature` for the last hour, assuming temperature is submitted once per minute:
|
216
216
|
|
217
|
-
data = Librato::Metrics.get_composite 'moving_average(mean(series("temperature", "*"), {size: "5"}))', :
|
217
|
+
data = Librato::Metrics.get_composite 'moving_average(mean(series("temperature", "*"), {size: "5"}))', start_time: Time.now.to_i - 60*60, resolution: 300
|
218
218
|
|
219
219
|
There are many more options supported for querying, take a look at the [REST API docs](http://dev.librato.com/v1/get/metrics/:name) or the individual method documentation for more details.
|
220
220
|
|
@@ -223,7 +223,7 @@ There are many more options supported for querying, take a look at the [REST API
|
|
223
223
|
Setting custom [properties](http://dev.librato.com/v1/metrics#metric_properties) on your metrics is easy:
|
224
224
|
|
225
225
|
# assign a period and default color
|
226
|
-
Librato::Metrics.update_metric :temperature, :
|
226
|
+
Librato::Metrics.update_metric :temperature, period: 15, attributes: { color: 'F00' }
|
227
227
|
|
228
228
|
It is also possible to update properties for multiple metrics at once, see the [`#update_metric` method documentation](http://rubydoc.info/github/librato/librato-metrics/master/Librato/Metrics/Client#update_metric-instance_method) for more information.
|
229
229
|
|
@@ -237,7 +237,7 @@ If you ever need to remove a metric and all of its measurements, doing so is eas
|
|
237
237
|
You can also delete using wildcards:
|
238
238
|
|
239
239
|
# delete metrics that start with cpu. except for cpu.free
|
240
|
-
Librato::Metrics.delete_metrics :
|
240
|
+
Librato::Metrics.delete_metrics names: 'cpu.*', exclude: ['cpu.free']
|
241
241
|
|
242
242
|
Note that deleted metrics and their measurements are unrecoverable, so use with care.
|
243
243
|
|
@@ -257,17 +257,17 @@ All of the same operations you can call directly from `Librato::Metrics` are ava
|
|
257
257
|
joe.metrics
|
258
258
|
|
259
259
|
# fetch the last 20 data points for Mike's metric, humidity
|
260
|
-
mike.get_measurements :humidity, :
|
260
|
+
mike.get_measurements :humidity, count: 20
|
261
261
|
|
262
262
|
There are two ways to associate a new queue with a client:
|
263
263
|
|
264
264
|
# these are functionally equivalent
|
265
|
-
joe_queue = Librato::Metrics::Queue.new(:
|
265
|
+
joe_queue = Librato::Metrics::Queue.new(client: joe)
|
266
266
|
joe_queue = joe.new_queue
|
267
267
|
|
268
268
|
Once the queue is associated you can use it normally:
|
269
269
|
|
270
|
-
joe_queue.add :
|
270
|
+
joe_queue.add temperature: {source: 'sf', value: 65.2}
|
271
271
|
joe_queue.submit
|
272
272
|
|
273
273
|
## Thread Safety
|
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ Bundler::GemHelper.install_tasks
|
|
11
11
|
# Gem signing
|
12
12
|
task 'before_build' do
|
13
13
|
signing_key = File.expand_path("~/.gem/librato-private_key.pem")
|
14
|
-
if
|
14
|
+
if signing_key
|
15
15
|
puts "Key found: signing gem..."
|
16
16
|
ENV['GEM_SIGNING_KEY'] = signing_key
|
17
17
|
else
|
@@ -45,8 +45,8 @@ namespace :spec do
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
task :
|
49
|
-
task :
|
48
|
+
task default: :spec
|
49
|
+
task test: :spec
|
50
50
|
|
51
51
|
# Docs
|
52
52
|
require 'yard'
|
@@ -61,4 +61,3 @@ task :console do
|
|
61
61
|
sh "irb -rubygems -r ./lib/librato/metrics.rb"
|
62
62
|
end
|
63
63
|
end
|
64
|
-
|
data/certs/librato-public.pem
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
2
|
+
MIIDLjCCAhagAwIBAgIBADANBgkqhkiG9w0BAQUFADA9MQ0wCwYDVQQDDARtYXR0
|
3
|
+
MRcwFQYKCZImiZPyLGQBGRYHbGlicmF0bzETMBEGCgmSJomT8ixkARkWA2NvbTAe
|
4
|
+
Fw0xNTEwMTIyMjA0MzVaFw0xNjEwMTEyMjA0MzVaMD0xDTALBgNVBAMMBG1hdHQx
|
5
|
+
FzAVBgoJkiaJk/IsZAEZFgdsaWJyYXRvMRMwEQYKCZImiZPyLGQBGRYDY29tMIIB
|
6
|
+
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvfN8RlAsUs+K5kK46SkhpYey
|
7
|
+
54m5bXlGZeqIguOygpG+2FJrUJMCnkQ9RmyK0WUjdmANevW01caQQSx5WatQZso0
|
8
|
+
GfJyJfKn4dGecz9LOEPpblw++qapLXr4vbuOlNXsum2gdUFc4/YV9l3csxClMVEq
|
9
|
+
+ZUmrHjd2koOvzjK+GDRf3iIozCsgY0oeserZ0li/0qRA5ZJeFwWzs9FO9SXPvID
|
10
|
+
Mk07WNaXSRT38llcPGX4L8K+DL7whQwxaFj6IZbobUEtRjzV9v/iP7PiJipijbKB
|
11
|
+
EiefgUuolRR38NxQE+f4M/lEqwEpkY/feYMYF6Q4hXVruG3fswjrDGWyiG5nEQID
|
12
|
+
AQABozkwNzAJBgNVHRMEAjAAMB0GA1UdDgQWBBR8+l0ZSTbj/TT6YVbFFpdGpg7q
|
13
|
+
UDALBgNVHQ8EBAMCBLAwDQYJKoZIhvcNAQEFBQADggEBAKuUiuG2PHv6paQjXjaZ
|
14
|
+
LQOsFunScHyhDhPFh/CcCUDbmXVDOJ3WIyDVQuUgK7I3jPEDaSFezSPBpjwZvgMK
|
15
|
+
0/in7pXLRKjI8CzsY8Y4u122DN9tBxLur+E/kv5fpUbf8FGUSuRT5X3wh6ZBTzsZ
|
16
|
+
EaMe3LpPFUeMShH/H/FEYrexRvaMHo/52Bg0zP0ySSAQDotm+qgMdru2XRDjE5Ms
|
17
|
+
9BheAnoygGHpoKWtExpsklCppL1q2Xlzw2lhoCMLCSSj9T/YyRTL3UQYoK5pPA76
|
18
|
+
hvjx0WJP8pzZMJPKJBRZQXJO5ifEPyKjZyMi5XMHmrtDclHLj3sx4RAvEZjGWkRP
|
19
|
+
JSQ=
|
20
20
|
-----END CERTIFICATE-----
|
data/examples/simple.rb
CHANGED
@@ -3,13 +3,13 @@ require 'librato/metrics'
|
|
3
3
|
Librato::Metrics.authenticate 'my email', 'my api key'
|
4
4
|
|
5
5
|
# send a measurement of 12 for 'foo'
|
6
|
-
Librato::Metrics.submit :
|
6
|
+
Librato::Metrics.submit cpu: 54
|
7
7
|
|
8
8
|
# submit multiple metrics at once
|
9
|
-
Librato::Metrics.submit :
|
9
|
+
Librato::Metrics.submit cpu: 63, memory: 213
|
10
10
|
|
11
11
|
# submit a metric with a custom source
|
12
|
-
Librato::Metrics.submit :
|
12
|
+
Librato::Metrics.submit cpu: {source: 'myapp', value: 75}
|
13
13
|
|
14
14
|
# if you are sending many metrics it is much more performant
|
15
15
|
# to submit them in sets rather than individually:
|
@@ -17,8 +17,8 @@ Librato::Metrics.submit :cpu => {:source => 'myapp', :value => 75}
|
|
17
17
|
queue = Librato::Metrics::Queue.new
|
18
18
|
|
19
19
|
queue.add 'disk.free' => 1223121
|
20
|
-
queue.add :
|
21
|
-
queue.add :
|
20
|
+
queue.add memory: 2321
|
21
|
+
queue.add cpu: {source: 'myapp', value: 52}
|
22
22
|
#...
|
23
23
|
|
24
24
|
queue.submit
|
data/lib/librato/metrics.rb
CHANGED
@@ -26,20 +26,20 @@ module Librato
|
|
26
26
|
# Librato::Metrics.authenticate 'email', 'api_key'
|
27
27
|
#
|
28
28
|
# # list current metrics
|
29
|
-
# Librato::Metrics.
|
29
|
+
# Librato::Metrics.metrics
|
30
30
|
#
|
31
31
|
# # submit a metric immediately
|
32
|
-
# Librato::Metrics.submit :
|
32
|
+
# Librato::Metrics.submit foo: 12712
|
33
33
|
#
|
34
34
|
# # fetch the last 10 values of foo
|
35
|
-
# Librato::Metrics.get_measurements :foo, :
|
35
|
+
# Librato::Metrics.get_measurements :foo, count: 10
|
36
36
|
#
|
37
37
|
# @example Queuing metrics for submission
|
38
38
|
# queue = Librato::Metrics::Queue.new
|
39
39
|
#
|
40
40
|
# # queue some metrics
|
41
|
-
# queue.add :
|
42
|
-
# queue.add :
|
41
|
+
# queue.add foo: 12312
|
42
|
+
# queue.add bar: 45678
|
43
43
|
#
|
44
44
|
# # send the metrics
|
45
45
|
# queue.submit
|
@@ -49,14 +49,14 @@ module Librato
|
|
49
49
|
# client.authenticate 'email', 'api_key'
|
50
50
|
#
|
51
51
|
# # list client's metrics
|
52
|
-
# client.
|
52
|
+
# client.metrics
|
53
53
|
#
|
54
54
|
# # create an associated queue
|
55
55
|
# queue = client.new_queue
|
56
56
|
#
|
57
57
|
# # queue up some metrics and submit
|
58
|
-
# queue.add :
|
59
|
-
# queue.add :
|
58
|
+
# queue.add foo: 12345
|
59
|
+
# queue.add bar: 45678
|
60
60
|
# queue.submit
|
61
61
|
#
|
62
62
|
# @note Most of the methods you can call directly on Librato::Metrics are
|
@@ -81,10 +81,7 @@ module Librato
|
|
81
81
|
:delete_metrics, :update_metric, :update_metrics,
|
82
82
|
:submit,
|
83
83
|
:sources, :get_source, :update_source,
|
84
|
-
:create_snapshot, :get_snapshot
|
85
|
-
# Deprecated metrics methods
|
86
|
-
:fetch, :list, :delete, :update
|
87
|
-
|
84
|
+
:create_snapshot, :get_snapshot
|
88
85
|
|
89
86
|
# The Librato::Metrics::Client being used by module-level
|
90
87
|
# access.
|
@@ -97,20 +97,20 @@ module Librato
|
|
97
97
|
metric, source = metric.split(SOURCE_SEPARATOR)
|
98
98
|
end
|
99
99
|
entry = {
|
100
|
-
:
|
101
|
-
:
|
102
|
-
:
|
100
|
+
name: metric,
|
101
|
+
count: data.count,
|
102
|
+
sum: data.sum,
|
103
103
|
|
104
104
|
# TODO: make float/non-float consistent in the gem
|
105
|
-
:
|
106
|
-
:
|
105
|
+
min: data.min.to_f,
|
106
|
+
max: data.max.to_f
|
107
107
|
# TODO: expose v.sum2 and include
|
108
108
|
}
|
109
109
|
entry[:source] = source if source
|
110
110
|
gauges << entry
|
111
111
|
end
|
112
112
|
|
113
|
-
req = { :
|
113
|
+
req = { gauges: gauges }
|
114
114
|
req[:source] = @source if @source
|
115
115
|
req[:measure_time] = @measure_time if @measure_time
|
116
116
|
|