process_metrics 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60c71413069134039aeacc1348863efe45184b24
4
- data.tar.gz: ec20a17b8047721208c0ac6b3135f424b3df31f5
3
+ metadata.gz: 8b331c9cfccd3e5c24116443a517f718747f9225
4
+ data.tar.gz: f0f0d192557863e47134a87cf4092712c127e0b6
5
5
  SHA512:
6
- metadata.gz: 638f0704e0ba772963b5f72f36773a46d8661750d232ddbc979afa5facbb34e0f29982da40ab7759971398da4052ca17267ff1c088f85ab688459074340e97e9
7
- data.tar.gz: b10606a34d866cca1abaa4d78c94c4e156ce824f4f5735d54ebd2a645a00885f5b68902e00e62e86ed85900d02f2c34821206585d837108d7e93d2d2aa58127a
6
+ metadata.gz: 3171ac04f714d7029e4ec6daf6a76a3cc1ba62e89aabe3d4b02fb8be543dd3c1fc9c9502a9f2ff1680bb70e06ed972e32529430fbb36ae05590f79699fff1b59
7
+ data.tar.gz: db34cee005261b585a6d69c0a154b232fb417aa36a5c3f653ba9a19a869641c806241f24ac4174c5f4c75140e2eabcb7476b0c3d5b1e33d038d697c04ae3533b
@@ -8,11 +8,11 @@ module ProcessMetrics
8
8
  self.logger = Logger.new("metric.log")
9
9
  self.persistence = ProcessMetrics::Persistence::Logger
10
10
  self.active_record = Hashie::Mash.new
11
- self.active_record.table_name = 'metrics'
11
+ self.active_record = nil
12
12
  end
13
13
  end
14
14
 
15
15
  def self.config
16
- Config.new
16
+ @@config ||= Config.new
17
17
  end
18
18
  end
@@ -1,56 +1,56 @@
1
- module ClassMethods
2
- @@replacing = false
1
+ module ProcessMetrics
2
+ module ClassMethods
3
+ @@replacing = false
3
4
 
4
- def measure(*methods_names)
5
- options = extract_options(methods_names)
5
+ def measure(*methods_names)
6
+ options = extract_options(methods_names)
6
7
 
7
- methods_names.each do |method_name|
8
- measure_method_name = :"measure_#{method_name}"
9
- raw_method_name = :"raw_#{method_name}"
10
- self.send(:define_method, measure_method_name) do |*args, &block|
11
- parent_uuid = parent_uuid(options)
12
- process_name = "#{self.class.name}##{method_name}"
13
- parent = ProcessMetrics::Base.new(process_name)
14
- parent.uuid = parent_uuid
8
+ methods_names.each do |method_name|
9
+ measure_method_name = :"measure_#{method_name}"
10
+ raw_method_name = :"raw_#{method_name}"
11
+ self.send(:define_method, measure_method_name) do |*args, &block|
12
+ parent_uuid = parent_uuid(options)
13
+ process_name = "#{self.class.name}##{method_name}"
14
+ parent = ProcessMetrics::Base.new(process_name)
15
+ parent.uuid = parent_uuid
15
16
 
16
- ProcessMetrics.measure(process_name, parent) do |metric|
17
- ProcessMetrics.logger.debug "About to send #{raw_method_name} with args #{args.inspect} and block #{block.inspect} to #{self}"
18
- metric.data = {args: args, block: block}
17
+ ProcessMetrics.measure(process_name, parent) do |metric|
18
+ ProcessMetrics.logger.debug "About to send #{raw_method_name} with args #{args.inspect} and block #{block.inspect} to #{self}"
19
+ metric.data = {args: args, block: block}
19
20
 
20
- send(raw_method_name, *args, &block)
21
+ send(raw_method_name, *args, &block)
22
+ end
21
23
  end
22
24
  end
23
25
  end
24
- end
25
26
 
26
- def method_added(method_name)
27
- return if @@replacing || method_name =~ /^measure_/ || method_name =~ /^raw_/
28
- ProcessMetrics.logger.debug "Adding method #{method_name} in #{self}"
27
+ def method_added(method_name)
28
+ return if @@replacing || method_name =~ /^measure_/ || method_name =~ /^raw_/
29
+ ProcessMetrics.logger.debug "Adding method #{method_name} in #{self}"
29
30
 
30
- measure_method_name = :"measure_#{method_name}"
31
- raw_method_name = :"raw_#{method_name}"
31
+ measure_method_name = :"measure_#{method_name}"
32
+ raw_method_name = :"raw_#{method_name}"
32
33
 
33
- if self.instance_methods.include? measure_method_name
34
- ProcessMetrics.logger.debug "#{self}##{measure_method_name} exists. Replacing..."
35
- @@replacing = true
36
- alias_method raw_method_name, method_name
37
- alias_method method_name, measure_method_name
38
- @@replacing = false
39
- else
40
- ProcessMetrics.logger.debug "#{self}##{measure_method_name} does not exist. Exiting..."
34
+ if self.instance_methods.include? measure_method_name
35
+ ProcessMetrics.logger.debug "#{self}##{measure_method_name} exists. Replacing..."
36
+ @@replacing = true
37
+ alias_method raw_method_name, method_name
38
+ alias_method method_name, measure_method_name
39
+ @@replacing = false
40
+ else
41
+ ProcessMetrics.logger.debug "#{self}##{measure_method_name} does not exist. Exiting..."
42
+ end
41
43
  end
42
- end
43
44
 
44
- private
45
- def extract_options(array)
46
- array.last && array.last.is_a?(Hash) ? array.pop : nil
45
+ private
46
+ def extract_options(array)
47
+ array.last && array.last.is_a?(Hash) ? array.pop : nil
48
+ end
47
49
  end
48
- end
49
50
 
50
- module ProcessMetrics
51
51
  module Timer
52
52
  def self.included(base)
53
- base.extend ClassMethods
53
+ base.extend ProcessMetrics::ClassMethods
54
54
  end
55
55
 
56
56
  def parent_uuid(options)
@@ -1,3 +1,3 @@
1
1
  module ProcessMetrics
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: process_metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Uyezu