librato-metrics 1.3.0 → 1.3.1

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 CHANGED
@@ -1,4 +1,2 @@
1
- k6A��IM71 �Q-�pE�
2
- 'd�Je�$xB6�u��^]S-2dw�
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�.hD(
2
+ "�=Y@��@�1Ν%.nj��j�ߓ�ii)䱺Ձ�޳�Y���rB:&��In4{nf3��W܊���� �9����8*��t{���[�/��wUt��bٗ
data/.travis.yml CHANGED
@@ -4,10 +4,9 @@ rvm:
4
4
  - 1.9.2
5
5
  - 1.9.3
6
6
  - 2.0.0
7
+ - 2.1.0
7
8
  - jruby-19mode
8
- - jruby-18mode
9
- - rbx-19mode
10
- - rbx-18mode
9
+ # - rbx
11
10
  - ruby-head
12
11
 
13
12
  matrix:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## Changelog
2
2
 
3
+ ### Version 1.3.1
4
+ * Fix auto-chunking for large measurements sets with a global source
5
+
3
6
  ### Version 1.3.0
4
7
  * Add support for working with sources as a first-class entity
5
8
 
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
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. Specifically for time-based autosubmission if you are adding measurements irregularly (less than once per second), submission may lag past your specified interval until the next measurement is added.
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
- queued.each do |metric_type, measurements|
32
- if measurements.size <= per_request
33
- # we can fit all of this metric type in a single
34
- # request, so do so
35
- reqs << {metric_type => measurements}
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
- measurements.each_slice(per_request) do |elements|
39
- reqs << {metric_type => elements}
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
@@ -1,5 +1,5 @@
1
1
  module Librato
2
2
  module Metrics
3
- VERSION = "1.3.0"
3
+ VERSION = "1.3.1"
4
4
  end
5
5
  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.0
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: 2013-11-19 00:00:00.000000000 Z
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: 694362489325963939
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