librato-metrics 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## Changelog
2
2
 
3
+ ### Version 0.7.1
4
+ * Add prefix option to Queues
5
+
3
6
  ### Version 0.7.0
4
7
  * Add ability to update metric properties (Christoph Bünte)
5
8
  * Add ability to merge queue and aggregator data into a queue
@@ -59,10 +59,11 @@ module Librato
59
59
  # @param [Hash] options Metric options
60
60
  def time(name, options={})
61
61
  start = Time.now
62
- yield
63
- duration = (Time.now - start) * 1000.0 # milliseconds
64
- metric = {name => options.merge({:value => duration})}
65
- add metric
62
+ yield.tap do
63
+ duration = (Time.now - start) * 1000.0 # milliseconds
64
+ metric = {name => options.merge({:value => duration})}
65
+ add metric
66
+ end
66
67
  end
67
68
  alias :benchmark :time
68
69
 
@@ -84,6 +85,7 @@ module Librato
84
85
  @source = options[:source]
85
86
  @create_time = Time.now
86
87
  @clear_on_failure = options[:clear_failures] || false
88
+ @prefix = options[:prefix]
87
89
  end
88
90
 
89
91
  def autosubmit_check
@@ -96,4 +98,4 @@ module Librato
96
98
  end
97
99
 
98
100
  end
99
- end
101
+ end
@@ -28,6 +28,9 @@ module Librato
28
28
  metric = {:name => key.to_s, :value => value}
29
29
  type = :gauge
30
30
  end
31
+ if @prefix
32
+ metric[:name] = "#{@prefix}.#{metric[:name]}"
33
+ end
31
34
  type = ("#{type}s").to_sym
32
35
  if metric[:measure_time]
33
36
  check_measure_time(metric)
@@ -1,5 +1,5 @@
1
1
  module Librato
2
2
  module Metrics
3
- VERSION = "0.7.0"
3
+ VERSION = "0.7.1"
4
4
  end
5
5
  end
@@ -182,6 +182,14 @@ module Librato
182
182
  queued[:sum].should be >= 500.0
183
183
  queued[:sum].should be_within(150).of(500)
184
184
  end
185
+
186
+ it "should return the result of the block" do
187
+ result = subject.time :returning do
188
+ :hi_there
189
+ end
190
+
191
+ result.should == :hi_there
192
+ end
185
193
  end
186
194
  end
187
195
 
@@ -71,6 +71,17 @@ module Librato
71
71
  :source => 'db2'}]}
72
72
  subject.queued.should equal_unordered(expected)
73
73
  end
74
+
75
+ context "with a prefix set" do
76
+ it "should auto-prepend names" do
77
+ subject = Queue.new(:prefix => 'foo')
78
+ subject.add :bar => 1
79
+ subject.add :baz => {:value => 23}
80
+ expected = {:gauges => [{:name =>'foo.bar', :value => 1, :measure_time => @time},
81
+ {:name => 'foo.baz', :value => 23, :measure_time => @time}]}
82
+ subject.queued.should equal_unordered(expected)
83
+ end
84
+ end
74
85
  end
75
86
 
76
87
  context "with multiple metrics" 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: 0.7.0
4
+ version: 0.7.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-25 00:00:00.000000000 Z
12
+ date: 2012-10-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -215,7 +215,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
215
215
  version: '0'
216
216
  segments:
217
217
  - 0
218
- hash: -1999246465148166572
218
+ hash: -2663483251500342035
219
219
  required_rubygems_version: !ruby/object:Gem::Requirement
220
220
  none: false
221
221
  requirements: