librato-metrics 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.travis.yml +9 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile +14 -0
- data/README.md +5 -1
- data/lib/librato/metrics.rb +1 -1
- data/lib/librato/metrics/client.rb +27 -3
- data/lib/librato/metrics/version.rb +1 -1
- data/librato-metrics.gemspec +0 -8
- data/spec/integration/metrics_spec.rb +32 -29
- metadata +3 -99
- metadata.gz.sig +7 -1
data.tar.gz.sig
CHANGED
Binary file
|
data/.travis.yml
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
rvm:
|
2
|
-
- 1.8.7
|
3
|
-
- ree
|
2
|
+
# - 1.8.7
|
3
|
+
# - ree
|
4
4
|
- 1.9.2
|
5
5
|
- 1.9.3
|
6
6
|
- 2.0.0
|
7
|
-
- 2.1.
|
7
|
+
- 2.1.2
|
8
8
|
- jruby-19mode
|
9
9
|
# - rbx
|
10
10
|
- ruby-head
|
@@ -15,4 +15,9 @@ matrix:
|
|
15
15
|
|
16
16
|
branches:
|
17
17
|
except:
|
18
|
-
- /^v[0-9]/
|
18
|
+
- /^v[0-9]/
|
19
|
+
|
20
|
+
notifications:
|
21
|
+
email:
|
22
|
+
on_failure: change
|
23
|
+
on_success: never
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -212,7 +212,11 @@ Get the 20 most recent 15 minute data point rollups for `temperature`:
|
|
212
212
|
|
213
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
|
+
|
217
|
+
data = Librato::Metrics.get_composite 'moving_average(mean(series("temperature", "*"), {size: "5"}))', :start_time => Time.now.to_i - 60*60, :resolution => 300
|
218
|
+
|
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.
|
216
220
|
|
217
221
|
## Setting Metric Properties
|
218
222
|
|
data/lib/librato/metrics.rb
CHANGED
@@ -76,7 +76,7 @@ module Librato
|
|
76
76
|
:api_endpoint=, :authenticate, :connection,
|
77
77
|
:faraday_adapter, :faraday_adapter=,
|
78
78
|
:persistence, :persistence=, :persister,
|
79
|
-
:get_metric, :get_measurements, :metrics,
|
79
|
+
:get_composite, :get_metric, :get_measurements, :metrics,
|
80
80
|
:delete_metrics, :update_metric, :update_metrics,
|
81
81
|
:submit,
|
82
82
|
:sources, :get_source, :update_source,
|
@@ -163,13 +163,37 @@ module Librato
|
|
163
163
|
options.empty? ? metric : metric["measurements"]
|
164
164
|
end
|
165
165
|
|
166
|
+
# Retrieve measurements for a given composite metric definition.
|
167
|
+
# :start_time and :resolution are required options, :end_time is
|
168
|
+
# optional.
|
169
|
+
#
|
170
|
+
# @example Get 5m moving average of 'foo'
|
171
|
+
# measurements = Librato::Metrics.get_composite
|
172
|
+
# 'moving_average(mean(series("foo", "*"), {size: "5"}))',
|
173
|
+
# :start_time => Time.now.to_i - 60*60, :resolution => 300
|
174
|
+
#
|
175
|
+
# @param [String] definition Composite definition
|
176
|
+
# @param [hash] options Query options
|
177
|
+
def get_composite(definition, options={})
|
178
|
+
unless options[:start_time] && options[:resolution]
|
179
|
+
raise "You must provide a :start_time and :resolution"
|
180
|
+
end
|
181
|
+
query = options.dup
|
182
|
+
query[:compose] = definition
|
183
|
+
url = connection.build_url("metrics", query)
|
184
|
+
response = connection.get(url)
|
185
|
+
parsed = SmartJSON.read(response.body)
|
186
|
+
# TODO: pagination support
|
187
|
+
parsed
|
188
|
+
end
|
189
|
+
|
166
190
|
# Retrieve a specific metric by name, optionally including data points
|
167
191
|
#
|
168
192
|
# @example Get attributes for a metric
|
169
193
|
# metric = Librato::Metrics.get_metric :temperature
|
170
194
|
#
|
171
195
|
# @example Get a metric and its 20 most recent data points
|
172
|
-
# metric = Librato::Metrics.
|
196
|
+
# metric = Librato::Metrics.get_metric :temperature, :count => 20
|
173
197
|
# metric['measurements'] # => {...}
|
174
198
|
#
|
175
199
|
# A full list of query parameters can be found in the API
|
@@ -238,10 +262,10 @@ module Librato
|
|
238
262
|
# List currently existing metrics
|
239
263
|
#
|
240
264
|
# @example List all metrics
|
241
|
-
# Librato::Metrics.
|
265
|
+
# Librato::Metrics.metrics
|
242
266
|
#
|
243
267
|
# @example List metrics with 'foo' in the name
|
244
|
-
# Librato::Metrics.
|
268
|
+
# Librato::Metrics.metrics :name => 'foo'
|
245
269
|
#
|
246
270
|
# @param [Hash] options
|
247
271
|
def metrics(options={})
|
data/librato-metrics.gemspec
CHANGED
@@ -29,14 +29,6 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.add_dependency 'multi_json'
|
30
30
|
s.add_dependency 'aggregate', '~> 0.2.2'
|
31
31
|
|
32
|
-
## development dependencies
|
33
|
-
s.add_development_dependency 'rake'
|
34
|
-
s.add_development_dependency 'rspec', '~> 2.6.0'
|
35
|
-
s.add_development_dependency 'pry'
|
36
|
-
s.add_development_dependency 'yard'
|
37
|
-
s.add_development_dependency 'sinatra'
|
38
|
-
s.add_development_dependency 'popen4'
|
39
|
-
|
40
32
|
# omitting for now because jruby-19mode can't handle
|
41
33
|
#s.add_development_dependency 'rdiscount' # for yard
|
42
34
|
|
@@ -355,35 +355,38 @@ module Librato
|
|
355
355
|
|
356
356
|
end
|
357
357
|
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
358
|
+
# Note: These are challenging to test end-to-end, should probably
|
359
|
+
# unit test instead. Disabling for now.
|
360
|
+
#
|
361
|
+
# describe "Snapshots API" do
|
362
|
+
#
|
363
|
+
# let(:instrument_id) do
|
364
|
+
# instrument_options = {name: "Snapshot test subject"}
|
365
|
+
# conn = Metrics.connection
|
366
|
+
# resp = conn.post do |req|
|
367
|
+
# req.url conn.build_url("/v1/instruments")
|
368
|
+
# req.body = Librato::Metrics::SmartJSON.write(instrument_options)
|
369
|
+
# end
|
370
|
+
# instrument_id = Librato::Metrics::SmartJSON.read(resp.body)["id"]
|
371
|
+
# end
|
372
|
+
#
|
373
|
+
# let(:subject) do
|
374
|
+
# {instrument: {href: "http://api.librato.dev/v1/instruments/#{instrument_id}"}}
|
375
|
+
# end
|
376
|
+
#
|
377
|
+
# it "should #create_snapshot" do
|
378
|
+
# result = Metrics.create_snapshot(subject: subject)
|
379
|
+
# result["href"].should =~ /snapshots\/\d+$/
|
380
|
+
# end
|
381
|
+
#
|
382
|
+
# it "should #get_snapshot" do
|
383
|
+
# result = Metrics.create_snapshot(subject: subject)
|
384
|
+
# snapshot_id = result["href"][/(\d+)$/]
|
385
|
+
#
|
386
|
+
# result = Metrics.get_snapshot(snapshot_id)
|
387
|
+
# result["href"].should =~ /snapshots\/\d+$/
|
388
|
+
# end
|
389
|
+
# end
|
387
390
|
|
388
391
|
end
|
389
392
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: librato-metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
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: 2014-
|
40
|
+
date: 2014-11-06 00:00:00.000000000 Z
|
41
41
|
dependencies:
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: faraday
|
@@ -87,102 +87,6 @@ dependencies:
|
|
87
87
|
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 0.2.2
|
90
|
-
- !ruby/object:Gem::Dependency
|
91
|
-
name: rake
|
92
|
-
requirement: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
|
-
requirements:
|
95
|
-
- - ! '>='
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '0'
|
98
|
-
type: :development
|
99
|
-
prerelease: false
|
100
|
-
version_requirements: !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
|
-
requirements:
|
103
|
-
- - ! '>='
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
version: '0'
|
106
|
-
- !ruby/object:Gem::Dependency
|
107
|
-
name: rspec
|
108
|
-
requirement: !ruby/object:Gem::Requirement
|
109
|
-
none: false
|
110
|
-
requirements:
|
111
|
-
- - ~>
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
version: 2.6.0
|
114
|
-
type: :development
|
115
|
-
prerelease: false
|
116
|
-
version_requirements: !ruby/object:Gem::Requirement
|
117
|
-
none: false
|
118
|
-
requirements:
|
119
|
-
- - ~>
|
120
|
-
- !ruby/object:Gem::Version
|
121
|
-
version: 2.6.0
|
122
|
-
- !ruby/object:Gem::Dependency
|
123
|
-
name: pry
|
124
|
-
requirement: !ruby/object:Gem::Requirement
|
125
|
-
none: false
|
126
|
-
requirements:
|
127
|
-
- - ! '>='
|
128
|
-
- !ruby/object:Gem::Version
|
129
|
-
version: '0'
|
130
|
-
type: :development
|
131
|
-
prerelease: false
|
132
|
-
version_requirements: !ruby/object:Gem::Requirement
|
133
|
-
none: false
|
134
|
-
requirements:
|
135
|
-
- - ! '>='
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: '0'
|
138
|
-
- !ruby/object:Gem::Dependency
|
139
|
-
name: yard
|
140
|
-
requirement: !ruby/object:Gem::Requirement
|
141
|
-
none: false
|
142
|
-
requirements:
|
143
|
-
- - ! '>='
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
none: false
|
150
|
-
requirements:
|
151
|
-
- - ! '>='
|
152
|
-
- !ruby/object:Gem::Version
|
153
|
-
version: '0'
|
154
|
-
- !ruby/object:Gem::Dependency
|
155
|
-
name: sinatra
|
156
|
-
requirement: !ruby/object:Gem::Requirement
|
157
|
-
none: false
|
158
|
-
requirements:
|
159
|
-
- - ! '>='
|
160
|
-
- !ruby/object:Gem::Version
|
161
|
-
version: '0'
|
162
|
-
type: :development
|
163
|
-
prerelease: false
|
164
|
-
version_requirements: !ruby/object:Gem::Requirement
|
165
|
-
none: false
|
166
|
-
requirements:
|
167
|
-
- - ! '>='
|
168
|
-
- !ruby/object:Gem::Version
|
169
|
-
version: '0'
|
170
|
-
- !ruby/object:Gem::Dependency
|
171
|
-
name: popen4
|
172
|
-
requirement: !ruby/object:Gem::Requirement
|
173
|
-
none: false
|
174
|
-
requirements:
|
175
|
-
- - ! '>='
|
176
|
-
- !ruby/object:Gem::Version
|
177
|
-
version: '0'
|
178
|
-
type: :development
|
179
|
-
prerelease: false
|
180
|
-
version_requirements: !ruby/object:Gem::Requirement
|
181
|
-
none: false
|
182
|
-
requirements:
|
183
|
-
- - ! '>='
|
184
|
-
- !ruby/object:Gem::Version
|
185
|
-
version: '0'
|
186
90
|
description: An easy to use ruby wrapper for Librato's Metrics API
|
187
91
|
email: matt@librato.com
|
188
92
|
executables: []
|
@@ -251,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
251
155
|
version: '0'
|
252
156
|
segments:
|
253
157
|
- 0
|
254
|
-
hash: -
|
158
|
+
hash: -1761741790277116379
|
255
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
256
160
|
none: false
|
257
161
|
requirements:
|
metadata.gz.sig
CHANGED
@@ -1 +1,7 @@
|
|
1
|
-
|
1
|
+
���O
|
2
|
+
VڬG�������
|
3
|
+
��)�K2�á���<ө�Ԕ����)�^a�����Pun��%w�U�ML��
|
4
|
+
f)��� �Uʨ��9j�t�����NE�
|
5
|
+
>�02��nTx��F��Z&摽z�Վ�Z�I�"��q���;�)���n��4�~�WP
|
6
|
+
�̹���E'��H�
|
7
|
+
˃ps��ov\أ�Jy����h�d*0h
|