librato-metrics 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +2 -4
- data/.travis.yml +2 -3
- data/CHANGELOG.md +3 -0
- data/Gemfile +8 -2
- data/README.md +3 -1
- data/lib/librato/metrics/persistence/direct.rb +19 -7
- data/lib/librato/metrics/version.rb +1 -1
- data/spec/integration/metrics/queue_spec.rb +20 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
@@ -1,4 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
r��L�v}�L$��@3r{�Z�Rt��y�R�\�)���X����?M/� ��"k�b��7����x�¡+Y�Z��*�LI)5�����(�����p�9��tĬS:�Vpε.��U
|
4
|
-
�פ���{��q���D�;��k��&���a�g���M��2�)\Aq%EV�.X�ղ��ʾ嬓: ����;��=���n
|
1
|
+
~[�uJE�.h�D�(
|
2
|
+
"�=Y@��@�1Ν%.nj��j�ߓ�ii)䱺Ձ��Y���rB:&��I�n�4{nf�3��W܊�����9����8*��t{���[�/��wU�t��bٗ
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source "
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
3
|
platforms :jruby do
|
4
4
|
gem 'jruby-openssl'
|
@@ -9,7 +9,13 @@ platforms :ruby_19 do
|
|
9
9
|
gem 'redcarpet'
|
10
10
|
end
|
11
11
|
|
12
|
+
platforms :rbx do
|
13
|
+
# rubinius stdlib
|
14
|
+
gem 'rubysl', '~> 2.0'
|
15
|
+
gem 'rubinius-developer_tools'
|
16
|
+
end
|
17
|
+
|
12
18
|
gemspec
|
13
19
|
|
14
20
|
# easily generate test data
|
15
|
-
gem 'quixote'
|
21
|
+
gem 'quixote'
|
data/README.md
CHANGED
@@ -180,7 +180,9 @@ Both `Queue` and `Aggregator` support automatically submitting measurements on a
|
|
180
180
|
|
181
181
|
These options can also be combined for more flexible behavior.
|
182
182
|
|
183
|
-
Both options are driven by the addition of measurements.
|
183
|
+
Both options are driven by the addition of measurements. *If you are adding measurements irregularly (less than once per second), time-based submission may lag past your specified interval until the next measurement is added.*
|
184
|
+
|
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).
|
184
186
|
|
185
187
|
## Querying Metrics
|
186
188
|
|
@@ -5,6 +5,7 @@ module Librato
|
|
5
5
|
module Metrics
|
6
6
|
module Persistence
|
7
7
|
class Direct
|
8
|
+
MEASUREMENT_TYPES = [:gauges, :counters]
|
8
9
|
|
9
10
|
# Persist the queued metrics directly to the
|
10
11
|
# Metrics web API.
|
@@ -28,21 +29,32 @@ module Librato
|
|
28
29
|
def chunk_queued(queued, per_request)
|
29
30
|
return [queued] if queue_count(queued) <= per_request
|
30
31
|
reqs = []
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
# separate metric-containing values from global values
|
33
|
+
globals = fetch_globals(queued)
|
34
|
+
MEASUREMENT_TYPES.each do |metric_type|
|
35
|
+
metrics = queued[metric_type]
|
36
|
+
next unless metrics
|
37
|
+
if metrics.size <= per_request
|
38
|
+
# we can fit all of this metric type in a single request
|
39
|
+
reqs << build_request(metric_type, metrics, globals)
|
36
40
|
else
|
37
41
|
# going to have to split things up
|
38
|
-
|
39
|
-
reqs <<
|
42
|
+
metrics.each_slice(per_request) do |elements|
|
43
|
+
reqs << build_request(metric_type, elements, globals)
|
40
44
|
end
|
41
45
|
end
|
42
46
|
end
|
43
47
|
reqs
|
44
48
|
end
|
45
49
|
|
50
|
+
def build_request(type, metrics, globals)
|
51
|
+
{type => metrics}.merge(globals)
|
52
|
+
end
|
53
|
+
|
54
|
+
def fetch_globals(queued)
|
55
|
+
queued.reject {|k, v| MEASUREMENT_TYPES.include?(k)}
|
56
|
+
end
|
57
|
+
|
46
58
|
def queue_count(queued)
|
47
59
|
queued.inject(0) { |result, data| result + data.last.size }
|
48
60
|
end
|
@@ -35,6 +35,26 @@ module Librato
|
|
35
35
|
gauge = Metrics.get_measurements :gauge_5, :count => 1
|
36
36
|
gauge['unassigned'][0]['value'].should == 5
|
37
37
|
end
|
38
|
+
|
39
|
+
it "should apply globals to each request" do
|
40
|
+
source = 'yogi'
|
41
|
+
measure_time = Time.now.to_i-3
|
42
|
+
queue = Queue.new(
|
43
|
+
:per_request => 3,
|
44
|
+
:source => source,
|
45
|
+
:measure_time => measure_time,
|
46
|
+
:skip_measurement_times => true
|
47
|
+
)
|
48
|
+
(1..5).each do |i|
|
49
|
+
queue.add "gauge_#{i}" => 1
|
50
|
+
end
|
51
|
+
queue.submit
|
52
|
+
|
53
|
+
# verify globals have persisted for all requests
|
54
|
+
gauge = Metrics.get_measurements :gauge_5, :count => 1
|
55
|
+
gauge[source][0]["value"].should eq(1.0)
|
56
|
+
gauge[source][0]["measure_time"].should eq(measure_time)
|
57
|
+
end
|
38
58
|
end
|
39
59
|
|
40
60
|
it "should respect default and individual sources" do
|
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.3.
|
4
|
+
version: 1.3.1
|
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:
|
40
|
+
date: 2014-04-14 00:00:00.000000000 Z
|
41
41
|
dependencies:
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: faraday
|
@@ -251,7 +251,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
251
251
|
version: '0'
|
252
252
|
segments:
|
253
253
|
- 0
|
254
|
-
hash:
|
254
|
+
hash: -294425092678136572
|
255
255
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
256
256
|
none: false
|
257
257
|
requirements:
|
metadata.gz.sig
CHANGED
Binary file
|