formatted-metrics 0.2.2 → 0.2.3
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/lib/metrics/handler.rb +5 -0
- data/lib/metrics/instrumenter.rb +6 -1
- data/lib/metrics/version.rb +1 -1
- data/lib/metrics.rb +2 -2
- data/spec/metrics/instrumenter_spec.rb +14 -1
- metadata +4 -4
data/lib/metrics/handler.rb
CHANGED
@@ -18,10 +18,15 @@ module Metrics
|
|
18
18
|
# Returns an Array of Metrics::Instrumenters that were written to STDOUT.
|
19
19
|
def handle
|
20
20
|
write instrumenters
|
21
|
+
result
|
21
22
|
end
|
22
23
|
|
23
24
|
private
|
24
25
|
|
26
|
+
def result
|
27
|
+
instrumenters.last.result
|
28
|
+
end
|
29
|
+
|
25
30
|
def configuration
|
26
31
|
Metrics.configuration
|
27
32
|
end
|
data/lib/metrics/instrumenter.rb
CHANGED
@@ -38,6 +38,11 @@ module Metrics
|
|
38
38
|
options[:source]
|
39
39
|
end
|
40
40
|
|
41
|
+
def result
|
42
|
+
return nil unless block
|
43
|
+
@result ||= block.call
|
44
|
+
end
|
45
|
+
|
41
46
|
private
|
42
47
|
attr_reader :options, :block
|
43
48
|
|
@@ -48,7 +53,7 @@ module Metrics
|
|
48
53
|
def time
|
49
54
|
@time ||= begin
|
50
55
|
start = Time.now
|
51
|
-
|
56
|
+
result
|
52
57
|
(Time.now - start) * 1000.0
|
53
58
|
end
|
54
59
|
end
|
data/lib/metrics/version.rb
CHANGED
data/lib/metrics.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Metrics::Instrumenter do
|
4
|
-
let(:instrumenter) { described_class.new('rack.request') { } }
|
4
|
+
let(:instrumenter) { described_class.new('rack.request') { 'foo' } }
|
5
5
|
|
6
6
|
describe '.value' do
|
7
7
|
subject { instrumenter.value }
|
@@ -42,4 +42,17 @@ describe Metrics::Instrumenter do
|
|
42
42
|
it { should eq 'sidekiq' }
|
43
43
|
end
|
44
44
|
end
|
45
|
+
|
46
|
+
describe '.result' do
|
47
|
+
subject { instrumenter.result }
|
48
|
+
|
49
|
+
context 'with a block' do
|
50
|
+
it { should eq 'foo' }
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'with a value' do
|
54
|
+
let(:instrumenter) { described_class.new('jobs.busy', 10, units: 'jobs') }
|
55
|
+
it { should be_nil }
|
56
|
+
end
|
57
|
+
end
|
45
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formatted-metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
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: 2013-08-
|
12
|
+
date: 2013-08-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -106,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
106
|
version: '0'
|
107
107
|
segments:
|
108
108
|
- 0
|
109
|
-
hash:
|
109
|
+
hash: 4334694595459848801
|
110
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
111
|
none: false
|
112
112
|
requirements:
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: '0'
|
116
116
|
segments:
|
117
117
|
- 0
|
118
|
-
hash:
|
118
|
+
hash: 4334694595459848801
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
121
|
rubygems_version: 1.8.23
|