librato-metrics 0.6.0.pre3 → 0.6.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/.travis.yml +9 -2
- data/CHANGELOG.md +11 -0
- data/README.md +43 -3
- data/lib/librato/metrics.rb +4 -2
- data/lib/librato/metrics/aggregator.rb +4 -2
- data/lib/librato/metrics/client.rb +20 -0
- data/lib/librato/metrics/connection.rb +1 -1
- data/lib/librato/metrics/errors.rb +2 -1
- data/lib/librato/metrics/processor.rb +18 -2
- data/lib/librato/metrics/queue.rb +24 -7
- data/lib/librato/metrics/version.rb +1 -1
- data/librato-metrics.gemspec +3 -1
- data/spec/integration/metrics/queue_spec.rb +1 -0
- data/spec/integration/metrics_spec.rb +39 -0
- data/spec/unit/metrics/aggregator_spec.rb +27 -1
- data/spec/unit/metrics/queue/autosubmission_spec.rb +48 -0
- data/spec/unit/metrics/queue_spec.rb +44 -1
- metadata +25 -34
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
## Changelog
|
2
2
|
|
3
|
+
### Version 0.6.0
|
4
|
+
* Add Aggregator class for aggregating measurements client-side
|
5
|
+
* Queue and Aggregator can auto-submit on a time interval
|
6
|
+
* Queue can auto-submit on a specified volume of measurements
|
7
|
+
* Support deleting individual metrics
|
8
|
+
* Validate user-specified measurement times
|
9
|
+
* Update to MultiJSON 1.3 syntax
|
10
|
+
* Run tests for rubinius and jruby in both 1.8 and 1.9 modes
|
11
|
+
* Include request body in output for failed requests
|
12
|
+
* Documentation improvements
|
13
|
+
|
3
14
|
### Version 0.5.0
|
4
15
|
* Support using multiple accounts simultaneously via Client
|
5
16
|
* Switch network library to faraday for broader platform support and flexibility
|
data/README.md
CHANGED
@@ -48,8 +48,20 @@ Queue up a simple gauge metric named `temperature`:
|
|
48
48
|
|
49
49
|
queue = Librato::Metrics::Queue.new
|
50
50
|
queue.add :temperature => 32.2
|
51
|
+
|
52
|
+
While symbols are used by convention for metric names, strings will work just as well:
|
53
|
+
|
54
|
+
queue.add 'myapp.request_time' => 86.7
|
55
|
+
|
56
|
+
If you are tracking measurements over several seconds/minutes, the queue will handle storing measurement time for you (otherwise all metrics will be recorded as measured when they are submitted).
|
51
57
|
|
52
|
-
If you
|
58
|
+
If you want to specify a time other than queuing time for the measurement:
|
59
|
+
|
60
|
+
# use a epoch integer
|
61
|
+
queue.add :humidity => {:measure_time => 1336508422, :value => 48.2}
|
62
|
+
|
63
|
+
# use a Time object to correct for a 5 second delay
|
64
|
+
queue.add :humidity => {:measure_time => Time.now-5, :value => 37.6}
|
53
65
|
|
54
66
|
You can queue multiple metrics at once. Here's a gauge (`load`) and a counter (`visits`):
|
55
67
|
|
@@ -61,7 +73,7 @@ Queue up a metric with a specified source:
|
|
61
73
|
|
62
74
|
A complete [list of metric attributes](http://dev.librato.com/v1/metrics) is available in the [API documentation](http://dev.librato.com/v1).
|
63
75
|
|
64
|
-
|
76
|
+
Send currently queued measurements to Metrics:
|
65
77
|
|
66
78
|
queue.submit
|
67
79
|
|
@@ -90,7 +102,7 @@ You can aggregate multiple metrics at once:
|
|
90
102
|
|
91
103
|
aggregator.add :app_latency => 35.2, :db_latency => 120.7
|
92
104
|
|
93
|
-
Send the
|
105
|
+
Send the currently aggregated metrics to Metrics:
|
94
106
|
|
95
107
|
aggregator.submit
|
96
108
|
|
@@ -109,6 +121,25 @@ If you need extra attributes for a `Queue` timing measurement, simply add them o
|
|
109
121
|
queue.time :my_measurement, :source => 'app1' do
|
110
122
|
# do work...
|
111
123
|
end
|
124
|
+
|
125
|
+
## Auto-Submitting Metrics
|
126
|
+
|
127
|
+
Both `Queue` and `Aggregator` support automatically submitting measurements on a given time interval:
|
128
|
+
|
129
|
+
# submit once per minute
|
130
|
+
timed_queue = Librato::Metrics::Queue.new(:autosubmit_interval => 60)
|
131
|
+
|
132
|
+
# submit every 5 minutes
|
133
|
+
timed_aggregator = Librato::Metrics::Aggregator.new(:autosubmit_interval => 300)
|
134
|
+
|
135
|
+
`Queue` also supports auto-submission based on measurement volume:
|
136
|
+
|
137
|
+
# submit when the 400th measurement is queued
|
138
|
+
volume_queue = Librato::Metrics::Queue.new(:autosubmit_count => 400)
|
139
|
+
|
140
|
+
These options can also be combined for more flexible behavior.
|
141
|
+
|
142
|
+
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.
|
112
143
|
|
113
144
|
## Querying Metrics
|
114
145
|
|
@@ -140,6 +171,15 @@ Get the 20 most recent 15 minute data point rollups for `temperature`:
|
|
140
171
|
|
141
172
|
There are many more options supported for querying, take a look at the [REST API docs](http://dev.librato.com/v1/get/gauges/:name) or the [fetch documentation](http://rubydoc.info/github/librato/librato-metrics/master/Librato/Metrics.fetch) for more details.
|
142
173
|
|
174
|
+
## Deleting Metrics
|
175
|
+
|
176
|
+
If you ever need to remove a metric and all of its measurements, doing so is easy:
|
177
|
+
|
178
|
+
# Delete the metrics 'temperature' and 'humidity'
|
179
|
+
Librato::Metrics.delete :temperature, :humidity
|
180
|
+
|
181
|
+
Note that deleted metrics and their measurements are unrecoverable, so use with care.
|
182
|
+
|
143
183
|
## Using Multiple Accounts Simultaneously
|
144
184
|
|
145
185
|
If you need to use metrics with multiple sets of authentication credentials simultaneously, you can do it with `Client`:
|
data/lib/librato/metrics.rb
CHANGED
@@ -63,12 +63,14 @@ module Librato
|
|
63
63
|
extend SingleForwardable
|
64
64
|
|
65
65
|
TYPES = [:counter, :gauge]
|
66
|
+
MIN_MEASURE_TIME = (Time.now-(3600*24*365)).to_i
|
66
67
|
|
67
68
|
# Expose class methods of Simple via Metrics itself.
|
68
69
|
#
|
69
70
|
def_delegators :client, :agent_identifier, :api_endpoint,
|
70
|
-
:api_endpoint=, :authenticate, :connection, :
|
71
|
-
:list, :persistence, :persistence=, :persister,
|
71
|
+
:api_endpoint=, :authenticate, :connection, :delete,
|
72
|
+
:fetch, :list, :persistence, :persistence=, :persister,
|
73
|
+
:submit
|
72
74
|
|
73
75
|
# The Librato::Metrics::Client being used by module-level
|
74
76
|
# access.
|
@@ -11,13 +11,13 @@ module Librato
|
|
11
11
|
|
12
12
|
def initialize(options={})
|
13
13
|
@aggregated = {}
|
14
|
-
|
15
|
-
@source = options[:source]
|
14
|
+
setup_common_options(options)
|
16
15
|
end
|
17
16
|
|
18
17
|
# Add a metric entry to the metric set:
|
19
18
|
#
|
20
19
|
# @param Hash metrics metrics to add
|
20
|
+
# @return Aggregator returns self
|
21
21
|
def add(args)
|
22
22
|
args.each do |k, v|
|
23
23
|
value = v.respond_to?(:each) ? v[:value] : v
|
@@ -25,6 +25,8 @@ module Librato
|
|
25
25
|
@aggregated[k] ||= Aggregate.new
|
26
26
|
@aggregated[k] << value
|
27
27
|
end
|
28
|
+
autosubmit_check
|
29
|
+
self
|
28
30
|
end
|
29
31
|
|
30
32
|
# Returns true if aggregate contains no measurements
|
@@ -59,6 +59,26 @@ module Librato
|
|
59
59
|
raise CredentialsMissing unless (self.email and self.api_key)
|
60
60
|
@connection ||= Connection.new(:client => self, :api_endpoint => api_endpoint)
|
61
61
|
end
|
62
|
+
|
63
|
+
# Completely delete metrics with the given names. Be
|
64
|
+
# careful with this, this is instant and permanent.
|
65
|
+
#
|
66
|
+
# @example Delete metric 'temperature'
|
67
|
+
# Librato::Metrics.delete :temperature
|
68
|
+
#
|
69
|
+
# @example Delete metrics 'foo' and 'bar'
|
70
|
+
# Librato::Metrics.delete :foo, :bar
|
71
|
+
def delete(*metric_names)
|
72
|
+
raise(NoMetricsProvided, 'Metric name missing.') if metric_names.empty?
|
73
|
+
params = {:names => metric_names}
|
74
|
+
connection.delete do |request|
|
75
|
+
request.url connection.build_url("metrics")
|
76
|
+
request.body = MultiJson.dump(params)
|
77
|
+
end
|
78
|
+
# expects 204, middleware will raise exception
|
79
|
+
# otherwise.
|
80
|
+
true
|
81
|
+
end
|
62
82
|
|
63
83
|
# Query metric data
|
64
84
|
#
|
@@ -27,7 +27,7 @@ module Librato
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def transport
|
30
|
-
raise
|
30
|
+
raise(NoClientProvided, "No client provided.") unless @client
|
31
31
|
@transport ||= Faraday::Connection.new(:url => api_endpoint + "/v1/") do |f|
|
32
32
|
#f.use FaradayMiddleware::EncodeJson
|
33
33
|
f.use Librato::Metrics::Middleware::RequestBody
|
@@ -5,9 +5,10 @@ module Librato
|
|
5
5
|
class MetricsError < StandardError; end
|
6
6
|
|
7
7
|
class CredentialsMissing < MetricsError; end
|
8
|
-
class AgentInfoMissing < MetricsError; end
|
9
8
|
class NoMetricsQueued < MetricsError; end
|
9
|
+
class NoMetricsProvided < MetricsError; end
|
10
10
|
class NoClientProvided < MetricsError; end
|
11
|
+
class InvalidMeasureTime < MetricsError; end
|
11
12
|
|
12
13
|
class NetworkError < StandardError; end
|
13
14
|
|
@@ -4,7 +4,7 @@ module Librato
|
|
4
4
|
module Processor
|
5
5
|
MEASUREMENTS_PER_REQUEST = 500
|
6
6
|
|
7
|
-
attr_reader :per_request
|
7
|
+
attr_reader :per_request, :last_submit_time
|
8
8
|
|
9
9
|
# The current Client instance this queue is using to authenticate
|
10
10
|
# and connect to Librato Metrics. This will default to the primary
|
@@ -26,9 +26,10 @@ module Librato
|
|
26
26
|
#
|
27
27
|
# @return Boolean
|
28
28
|
def submit
|
29
|
-
raise
|
29
|
+
raise(NoMetricsQueued, "No metrics queued.") if self.queued.empty?
|
30
30
|
options = {:per_request => @per_request}
|
31
31
|
if persister.persist(self.client, self.queued, options)
|
32
|
+
@last_submit_time = Time.now
|
32
33
|
flush and return true
|
33
34
|
end
|
34
35
|
false
|
@@ -72,6 +73,21 @@ module Librato
|
|
72
73
|
Time.now.to_i
|
73
74
|
end
|
74
75
|
|
76
|
+
def setup_common_options(options)
|
77
|
+
@autosubmit_interval = options[:autosubmit_interval]
|
78
|
+
@client = options[:client] || Librato::Metrics.client
|
79
|
+
@per_request = options[:per_request] || MEASUREMENTS_PER_REQUEST
|
80
|
+
@source = options[:source]
|
81
|
+
@create_time = Time.now
|
82
|
+
end
|
83
|
+
|
84
|
+
def autosubmit_check
|
85
|
+
if @autosubmit_interval
|
86
|
+
last = @last_submit_time || @create_time
|
87
|
+
self.submit if (Time.now - last).to_i >= @autosubmit_interval
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
75
91
|
end
|
76
92
|
|
77
93
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'metrics/processor'
|
2
2
|
|
3
|
-
|
4
3
|
module Librato
|
5
4
|
module Metrics
|
6
5
|
class Queue
|
@@ -10,15 +9,15 @@ module Librato
|
|
10
9
|
|
11
10
|
def initialize(options={})
|
12
11
|
@queued = {}
|
13
|
-
@
|
14
|
-
@per_request = options[:per_request] || MEASUREMENTS_PER_REQUEST
|
12
|
+
@autosubmit_count = options[:autosubmit_count]
|
15
13
|
@skip_measurement_times = options[:skip_measurement_times]
|
14
|
+
setup_common_options(options)
|
16
15
|
end
|
17
16
|
|
18
17
|
# Add a metric entry to the metric set:
|
19
18
|
#
|
20
19
|
# @param Hash metrics metrics to add
|
21
|
-
# @return
|
20
|
+
# @return Queue returns self
|
22
21
|
def add(args)
|
23
22
|
args.each do |key, value|
|
24
23
|
if value.respond_to?(:each)
|
@@ -30,13 +29,16 @@ module Librato
|
|
30
29
|
type = :gauge
|
31
30
|
end
|
32
31
|
type = ("#{type}s").to_sym
|
33
|
-
|
34
|
-
metric
|
32
|
+
if metric[:measure_time]
|
33
|
+
check_measure_time(metric)
|
34
|
+
elsif !skip_measurement_times
|
35
|
+
metric[:measure_time] = epoch_time
|
35
36
|
end
|
36
37
|
@queued[type] ||= []
|
37
38
|
@queued[type] << metric
|
38
39
|
end
|
39
|
-
|
40
|
+
submit_check
|
41
|
+
self
|
40
42
|
end
|
41
43
|
|
42
44
|
# Currently queued counters
|
@@ -82,6 +84,21 @@ module Librato
|
|
82
84
|
self.queued.inject(0) { |result, data| result + data.last.size }
|
83
85
|
end
|
84
86
|
alias :length :size
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def check_measure_time(data)
|
91
|
+
if data[:measure_time].to_i < Metrics::MIN_MEASURE_TIME
|
92
|
+
raise InvalidMeasureTime, "Measure time for submitted metric (#{data}) is invalid."
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def submit_check
|
97
|
+
autosubmit_check # in Processor
|
98
|
+
if @autosubmit_count && self.length >= @autosubmit_count
|
99
|
+
self.submit
|
100
|
+
end
|
101
|
+
end
|
85
102
|
|
86
103
|
end
|
87
104
|
end
|
data/librato-metrics.gemspec
CHANGED
@@ -33,9 +33,11 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.add_development_dependency 'rspec', '~>2.6.0'
|
34
34
|
s.add_development_dependency 'pry'
|
35
35
|
s.add_development_dependency 'yard'
|
36
|
-
s.add_development_dependency 'rdiscount' # for yard
|
37
36
|
s.add_development_dependency 'sinatra'
|
38
37
|
s.add_development_dependency 'popen4'
|
38
|
+
|
39
|
+
# omitting for now because jruby-19mode can't handle
|
40
|
+
#s.add_development_dependency 'rdiscount' # for yard
|
39
41
|
|
40
42
|
s.files = `git ls-files`.split("\n")
|
41
43
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -4,6 +4,45 @@ module Librato
|
|
4
4
|
describe Metrics do
|
5
5
|
before(:all) { prep_integration_tests }
|
6
6
|
|
7
|
+
describe "#delete" do
|
8
|
+
before(:each) { delete_all_metrics }
|
9
|
+
|
10
|
+
context "with a single argument" do
|
11
|
+
it "should delete named metric" do
|
12
|
+
Metrics.submit :foo => 123
|
13
|
+
Metrics.list(:name => :foo).should_not be_empty
|
14
|
+
Metrics.delete :foo
|
15
|
+
Metrics.list(:name => :foo).should be_empty
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "with multiple arguments" do
|
20
|
+
it "should delete named metrics" do
|
21
|
+
Metrics.submit :foo => 123, :bar => 345, :baz => 567
|
22
|
+
Metrics.delete :foo, :bar
|
23
|
+
Metrics.list(:name => :foo).should be_empty
|
24
|
+
Metrics.list(:name => :bar).should be_empty
|
25
|
+
Metrics.list(:name => :baz).should_not be_empty
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "with missing metric" do
|
30
|
+
it "should run cleanly" do
|
31
|
+
# the API currently returns success even if
|
32
|
+
# the metric has already been deleted or is absent.
|
33
|
+
Metrics.delete :missing
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "with no arguments" do
|
38
|
+
it "should not make request" do
|
39
|
+
lambda {
|
40
|
+
Metrics.delete
|
41
|
+
}.should raise_error(Metrics::NoMetricsProvided)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
7
46
|
describe "#fetch" do
|
8
47
|
before(:all) do
|
9
48
|
delete_all_metrics
|
@@ -41,6 +41,10 @@ module Librato
|
|
41
41
|
end
|
42
42
|
|
43
43
|
describe "#add" do
|
44
|
+
it "should allow chaining" do
|
45
|
+
subject.add(:foo => 1234).should == subject
|
46
|
+
end
|
47
|
+
|
44
48
|
context "with single hash argument" do
|
45
49
|
it "should record a single aggregate" do
|
46
50
|
subject.add :foo => 3000
|
@@ -161,11 +165,33 @@ module Librato
|
|
161
165
|
queued = subject.queued[:gauges][0]
|
162
166
|
queued[:name].should == 'sleeping'
|
163
167
|
queued[:count].should be 5
|
164
|
-
queued[:sum].should be
|
168
|
+
queued[:sum].should be >= 500.0
|
165
169
|
queued[:sum].should be_within(150).of(500)
|
166
170
|
end
|
167
171
|
end
|
168
172
|
end
|
173
|
+
|
174
|
+
context "with an autosubmit interval" do
|
175
|
+
let(:client) do
|
176
|
+
client = Client.new
|
177
|
+
client.persistence = :test
|
178
|
+
client
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should not submit immediately" do
|
182
|
+
timed_agg = Aggregator.new(:client => client, :autosubmit_interval => 1)
|
183
|
+
timed_agg.add :foo => 1
|
184
|
+
timed_agg.persister.persisted.should be_nil # nothing sent
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should submit after interval" do
|
188
|
+
timed_agg = Aggregator.new(:client => client, :autosubmit_interval => 1)
|
189
|
+
timed_agg.add :foo => 1
|
190
|
+
sleep 1
|
191
|
+
timed_agg.add :foo => 2
|
192
|
+
timed_agg.persister.persisted.should_not be_nil # sent
|
193
|
+
end
|
194
|
+
end
|
169
195
|
|
170
196
|
end
|
171
197
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Librato
|
4
|
+
module Metrics
|
5
|
+
|
6
|
+
describe Queue do
|
7
|
+
|
8
|
+
let(:client) {
|
9
|
+
client = Client.new
|
10
|
+
client.persistence = :test
|
11
|
+
client
|
12
|
+
}
|
13
|
+
|
14
|
+
context "with an autosubmit count" do
|
15
|
+
it "should submit when the max is reached" do
|
16
|
+
vol_queue = Queue.new(:client => client, :autosubmit_count => 2)
|
17
|
+
vol_queue.add :foo => 1
|
18
|
+
vol_queue.add :bar => 2
|
19
|
+
vol_queue.persister.persisted.should_not be_nil # sent
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should not submit if the max has not been reached" do
|
23
|
+
vol_queue = Queue.new(:client => client, :autosubmit_count => 5)
|
24
|
+
vol_queue.add :foo => 1
|
25
|
+
vol_queue.add :bar => 2
|
26
|
+
vol_queue.persister.persisted.should be_nil # nothing sent
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "with an autosubmit interval" do
|
31
|
+
it "should not submit immediately" do
|
32
|
+
vol_queue = Queue.new(:client => client, :autosubmit_interval => 1)
|
33
|
+
vol_queue.add :foo => 1
|
34
|
+
vol_queue.persister.persisted.should be_nil # nothing sent
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should submit after interval" do
|
38
|
+
vol_queue = Queue.new(:client => client, :autosubmit_interval => 1)
|
39
|
+
vol_queue.add :foo => 1
|
40
|
+
sleep 1
|
41
|
+
vol_queue.add :foo => 2
|
42
|
+
vol_queue.persister.persisted.should_not be_nil # sent
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -28,6 +28,10 @@ module Librato
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "#add" do
|
31
|
+
it "should allow chaining" do
|
32
|
+
subject.add(:foo => 123).should == subject
|
33
|
+
end
|
34
|
+
|
31
35
|
context "with single hash argument" do
|
32
36
|
it "should record a key-value gauge" do
|
33
37
|
expected = {:gauges => [{:name => 'foo', :value => 3000, :measure_time => @time}]}
|
@@ -78,6 +82,32 @@ module Librato
|
|
78
82
|
subject.queued.should equal_unordered(expected)
|
79
83
|
end
|
80
84
|
end
|
85
|
+
|
86
|
+
context "with a measure_time" do
|
87
|
+
it "should accept time objects" do
|
88
|
+
time = Time.now-5
|
89
|
+
subject.add :foo => {:measure_time => time, :value => 123}
|
90
|
+
subject.queued[:gauges][0][:measure_time].should == time
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should accept integers" do
|
94
|
+
time = 1336574713
|
95
|
+
subject.add :foo => {:measure_time => time, :value => 123}
|
96
|
+
subject.queued[:gauges][0][:measure_time].should == time
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should accept strings" do
|
100
|
+
time = '1336574713'
|
101
|
+
subject.add :foo => {:measure_time => time, :value => 123}
|
102
|
+
subject.queued[:gauges][0][:measure_time].should == time
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should raise exception in invalid time" do
|
106
|
+
lambda {
|
107
|
+
subject.add :foo => {:measure_time => '12', :value => 123}
|
108
|
+
}.should raise_error(InvalidMeasureTime)
|
109
|
+
end
|
110
|
+
end
|
81
111
|
end
|
82
112
|
|
83
113
|
describe "#counters" do
|
@@ -115,6 +145,19 @@ module Librato
|
|
115
145
|
end
|
116
146
|
end
|
117
147
|
|
148
|
+
describe "#last_submit_time" do
|
149
|
+
it "should default to nil" do
|
150
|
+
subject.last_submit_time.should be_nil
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should store last submission time" do
|
154
|
+
prior = Time.now
|
155
|
+
subject.add :foo => 123
|
156
|
+
subject.submit
|
157
|
+
subject.last_submit_time.should >= prior
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
118
161
|
describe "#per_request" do
|
119
162
|
it "should default to 500" do
|
120
163
|
subject.per_request.should == 500
|
@@ -186,7 +229,7 @@ module Librato
|
|
186
229
|
end
|
187
230
|
end
|
188
231
|
|
189
|
-
end #
|
232
|
+
end # Queue
|
190
233
|
|
191
234
|
end
|
192
235
|
end
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: librato-metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.6.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Matt Sanders
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-09 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
16
|
-
requirement: &
|
16
|
+
requirement: &70349186771660 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.7.6
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70349186771660
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: multi_json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70349186771180 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.3.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70349186771180
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: aggregate
|
38
|
-
requirement: &
|
38
|
+
requirement: &70349186770720 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.2.2
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70349186770720
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &70349186802320 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70349186802320
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &70349186801780 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 2.6.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70349186801780
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pry
|
71
|
-
requirement: &
|
71
|
+
requirement: &70349186801360 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70349186801360
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: yard
|
82
|
-
requirement: &
|
82
|
+
requirement: &70349186800900 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,21 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
91
|
-
- !ruby/object:Gem::Dependency
|
92
|
-
name: rdiscount
|
93
|
-
requirement: &70105435067560 !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
|
-
requirements:
|
96
|
-
- - ! '>='
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: '0'
|
99
|
-
type: :development
|
100
|
-
prerelease: false
|
101
|
-
version_requirements: *70105435067560
|
90
|
+
version_requirements: *70349186800900
|
102
91
|
- !ruby/object:Gem::Dependency
|
103
92
|
name: sinatra
|
104
|
-
requirement: &
|
93
|
+
requirement: &70349186800480 !ruby/object:Gem::Requirement
|
105
94
|
none: false
|
106
95
|
requirements:
|
107
96
|
- - ! '>='
|
@@ -109,10 +98,10 @@ dependencies:
|
|
109
98
|
version: '0'
|
110
99
|
type: :development
|
111
100
|
prerelease: false
|
112
|
-
version_requirements: *
|
101
|
+
version_requirements: *70349186800480
|
113
102
|
- !ruby/object:Gem::Dependency
|
114
103
|
name: popen4
|
115
|
-
requirement: &
|
104
|
+
requirement: &70349186800060 !ruby/object:Gem::Requirement
|
116
105
|
none: false
|
117
106
|
requirements:
|
118
107
|
- - ! '>='
|
@@ -120,7 +109,7 @@ dependencies:
|
|
120
109
|
version: '0'
|
121
110
|
type: :development
|
122
111
|
prerelease: false
|
123
|
-
version_requirements: *
|
112
|
+
version_requirements: *70349186800060
|
124
113
|
description: An easy to use ruby wrapper for Librato's Metrics API
|
125
114
|
email: matt@librato.com
|
126
115
|
executables: []
|
@@ -162,6 +151,7 @@ files:
|
|
162
151
|
- spec/unit/metrics/aggregator_spec.rb
|
163
152
|
- spec/unit/metrics/client_spec.rb
|
164
153
|
- spec/unit/metrics/connection_spec.rb
|
154
|
+
- spec/unit/metrics/queue/autosubmission_spec.rb
|
165
155
|
- spec/unit/metrics/queue_spec.rb
|
166
156
|
- spec/unit/metrics_spec.rb
|
167
157
|
homepage: https://github.com/librato/librato-metrics
|
@@ -180,9 +170,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
180
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
171
|
none: false
|
182
172
|
requirements:
|
183
|
-
- - ! '
|
173
|
+
- - ! '>='
|
184
174
|
- !ruby/object:Gem::Version
|
185
|
-
version:
|
175
|
+
version: '0'
|
186
176
|
requirements: []
|
187
177
|
rubyforge_project:
|
188
178
|
rubygems_version: 1.8.16
|
@@ -199,6 +189,7 @@ test_files:
|
|
199
189
|
- spec/unit/metrics/aggregator_spec.rb
|
200
190
|
- spec/unit/metrics/client_spec.rb
|
201
191
|
- spec/unit/metrics/connection_spec.rb
|
192
|
+
- spec/unit/metrics/queue/autosubmission_spec.rb
|
202
193
|
- spec/unit/metrics/queue_spec.rb
|
203
194
|
- spec/unit/metrics_spec.rb
|
204
195
|
has_rdoc:
|