active_metrics 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/active_metrics.gemspec +0 -3
- data/lib/active_metrics/instrumentable.rb +22 -1
- data/lib/active_metrics/version.rb +1 -1
- metadata +21 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82af20ffaf35ac07447725515c74159d5d6c7605
|
4
|
+
data.tar.gz: 6398d51851ec95a8821e9c68343d5200a5a00197
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c631ce7c816a8ed6e7d57efa628d6f289c36c769b8ad7f52fd60775038137230c7fb116ec882fb106021bca5ffcf35734054e1055d649909d5c530a95e74479
|
7
|
+
data.tar.gz: c98272fcde5a3783f70b96189b8e1d17ea6dbdfd80dca23ed9f3a36b3d5facbaada2b4fee48c976286b61ce61e3d88bef5b8a2cefb86f35a046ff38862836af6
|
data/Gemfile.lock
CHANGED
data/active_metrics.gemspec
CHANGED
@@ -13,9 +13,6 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = 'https://github.com/andreimaxim/active_metrics'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
|
-
spec.cert_chain = ['certs/andreimaxim.pem']
|
17
|
-
spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $0 =~ /gem\z/
|
18
|
-
|
19
16
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
17
|
f.match(%r{^(test|spec|features)/})
|
21
18
|
end
|
@@ -24,10 +24,31 @@ module ActiveMetrics
|
|
24
24
|
# complete set of summary statistics over the measures submitted in that
|
25
25
|
# interval.
|
26
26
|
#
|
27
|
+
# The `measure` method also accepts a block of code which will automatically
|
28
|
+
# measure the amount of time spent running that block:
|
29
|
+
#
|
30
|
+
# measure 'foo.bar.baz' do
|
31
|
+
# Foo.bar #=> 'baz'
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# For convenience, when `measure` is used with a block it will return the
|
35
|
+
# value returned by the block.
|
36
|
+
#
|
27
37
|
# @param event [String] The name of the event
|
28
38
|
# @param value [Integer, String] The value measured.
|
29
39
|
def measure(event, value = 0)
|
30
|
-
|
40
|
+
if block_given?
|
41
|
+
time = Time.now
|
42
|
+
# Store the value returned by the block for future reference
|
43
|
+
value = yield
|
44
|
+
delta = Time.now - time
|
45
|
+
|
46
|
+
ActiveMetrics::Collector.record(event, { metric: 'measure', value: delta })
|
47
|
+
|
48
|
+
value
|
49
|
+
else
|
50
|
+
ActiveMetrics::Collector.record(event, { metric: 'measure', value: value })
|
51
|
+
end
|
31
52
|
end
|
32
53
|
|
33
54
|
# Sample metrics are used to convey simple key/numerical value pairs when
|
metadata
CHANGED
@@ -1,101 +1,100 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Maxim
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
|
-
cert_chain:
|
11
|
-
-
|
12
|
-
date: 2018-02-16 00:00:00.000000000 Z
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name: bundler
|
16
14
|
requirement: !ruby/object:Gem::Requirement
|
17
15
|
requirements:
|
18
16
|
- - "~>"
|
19
17
|
- !ruby/object:Gem::Version
|
20
18
|
version: '1.16'
|
21
|
-
|
19
|
+
name: bundler
|
22
20
|
prerelease: false
|
21
|
+
type: :development
|
23
22
|
version_requirements: !ruby/object:Gem::Requirement
|
24
23
|
requirements:
|
25
24
|
- - "~>"
|
26
25
|
- !ruby/object:Gem::Version
|
27
26
|
version: '1.16'
|
28
27
|
- !ruby/object:Gem::Dependency
|
29
|
-
name: rake
|
30
28
|
requirement: !ruby/object:Gem::Requirement
|
31
29
|
requirements:
|
32
30
|
- - "~>"
|
33
31
|
- !ruby/object:Gem::Version
|
34
32
|
version: '10.0'
|
35
|
-
|
33
|
+
name: rake
|
36
34
|
prerelease: false
|
35
|
+
type: :development
|
37
36
|
version_requirements: !ruby/object:Gem::Requirement
|
38
37
|
requirements:
|
39
38
|
- - "~>"
|
40
39
|
- !ruby/object:Gem::Version
|
41
40
|
version: '10.0'
|
42
41
|
- !ruby/object:Gem::Dependency
|
43
|
-
name: minitest
|
44
42
|
requirement: !ruby/object:Gem::Requirement
|
45
43
|
requirements:
|
46
44
|
- - "~>"
|
47
45
|
- !ruby/object:Gem::Version
|
48
46
|
version: '5.0'
|
49
|
-
|
47
|
+
name: minitest
|
50
48
|
prerelease: false
|
49
|
+
type: :development
|
51
50
|
version_requirements: !ruby/object:Gem::Requirement
|
52
51
|
requirements:
|
53
52
|
- - "~>"
|
54
53
|
- !ruby/object:Gem::Version
|
55
54
|
version: '5.0'
|
56
55
|
- !ruby/object:Gem::Dependency
|
57
|
-
name: simplecov
|
58
56
|
requirement: !ruby/object:Gem::Requirement
|
59
57
|
requirements:
|
60
58
|
- - "~>"
|
61
59
|
- !ruby/object:Gem::Version
|
62
60
|
version: '0.15'
|
63
|
-
|
61
|
+
name: simplecov
|
64
62
|
prerelease: false
|
63
|
+
type: :development
|
65
64
|
version_requirements: !ruby/object:Gem::Requirement
|
66
65
|
requirements:
|
67
66
|
- - "~>"
|
68
67
|
- !ruby/object:Gem::Version
|
69
68
|
version: '0.15'
|
70
69
|
- !ruby/object:Gem::Dependency
|
71
|
-
name: pry
|
72
70
|
requirement: !ruby/object:Gem::Requirement
|
73
71
|
requirements:
|
74
72
|
- - "~>"
|
75
73
|
- !ruby/object:Gem::Version
|
76
74
|
version: '0.11'
|
77
|
-
|
75
|
+
name: pry
|
78
76
|
prerelease: false
|
77
|
+
type: :development
|
79
78
|
version_requirements: !ruby/object:Gem::Requirement
|
80
79
|
requirements:
|
81
80
|
- - "~>"
|
82
81
|
- !ruby/object:Gem::Version
|
83
82
|
version: '0.11'
|
84
83
|
- !ruby/object:Gem::Dependency
|
85
|
-
name: activesupport
|
86
84
|
requirement: !ruby/object:Gem::Requirement
|
87
85
|
requirements:
|
88
86
|
- - ">="
|
89
87
|
- !ruby/object:Gem::Version
|
90
88
|
version: 3.0.0
|
91
|
-
|
89
|
+
name: activesupport
|
92
90
|
prerelease: false
|
91
|
+
type: :runtime
|
93
92
|
version_requirements: !ruby/object:Gem::Requirement
|
94
93
|
requirements:
|
95
94
|
- - ">="
|
96
95
|
- !ruby/object:Gem::Version
|
97
96
|
version: 3.0.0
|
98
|
-
description:
|
97
|
+
description:
|
99
98
|
email:
|
100
99
|
- andrei@andreimaxim.ro
|
101
100
|
executables: []
|
@@ -123,7 +122,7 @@ homepage: https://github.com/andreimaxim/active_metrics
|
|
123
122
|
licenses:
|
124
123
|
- MIT
|
125
124
|
metadata: {}
|
126
|
-
post_install_message:
|
125
|
+
post_install_message:
|
127
126
|
rdoc_options: []
|
128
127
|
require_paths:
|
129
128
|
- lib
|
@@ -138,9 +137,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
137
|
- !ruby/object:Gem::Version
|
139
138
|
version: '0'
|
140
139
|
requirements: []
|
141
|
-
rubyforge_project:
|
142
|
-
rubygems_version: 2.6.
|
143
|
-
signing_key:
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.6.14.1
|
142
|
+
signing_key:
|
144
143
|
specification_version: 4
|
145
144
|
summary: Metrics based on ActiveSupport::Notifications
|
146
145
|
test_files: []
|