process_metrics 0.1.10 → 0.1.11

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: 189b72f4713bbe95ffa5a6c2b0b7cae1a2cab7cd
4
- data.tar.gz: 88f03b1538c2bafb8fd5d54ae5851b8e8a665951
3
+ metadata.gz: 383e9dcb3f5badd628bbb727d281ffed8f74ec3f
4
+ data.tar.gz: 5e4b3e5e8c7558f6e15de2f0d31b09b01187f34b
5
5
  SHA512:
6
- metadata.gz: 83b71690117e9fe9618d9dc88bfdd4a00754d63bf77ccaae6f2955016421fcfc28399fe468b3267661521f4ae36e1c1eb63795dcdf2c622cdfc4d34365130228
7
- data.tar.gz: 400437c912e5a169a17638504f53db0dc45dd6a08a68188cddbda5b787289bb1c25edf8484a117e5f3ba2268d0546f900ebf3ad106cc010a45f78adb65863bc3
6
+ metadata.gz: bc2eb84eaf2f905af38ec71fe2575b585fedd9fb2610241041f9e7f16eeecf5e72a2d05f93406d5dd4d7b782a0e599af2e83428b671c0963219f6dc4ff895e15
7
+ data.tar.gz: bd9a4b81676021d2d12195e28f73a177481a395404c034845558c337c6c55bdac4b60cbd615104f613f95ec98f7118606d9793be626c72db6a689310c27766ed
@@ -36,13 +36,19 @@ module ProcessMetrics
36
36
  raw_method_name = :"raw_#{method_name}"
37
37
 
38
38
  self.send(:define_method, measure_method_name) do |*args, &block|
39
- parent_uuid = parent_uuid(options)
40
- process_name = "#{self.class.name}##{method_name}"
41
- parent = ProcessMetrics::Base.new(process_name)
42
- parent.uuid = parent_uuid
39
+ parent = nil
40
+ uuid = extract_option(options, :uuid)
41
+ parent_uuid = extract_option(options, :parent_uuid)
42
+ process_name = extract_option(options, :name) || "#{self.class.name}##{method_name}"
43
+
44
+ if parent_uuid
45
+ parent = ProcessMetrics::Base.new(process_name)
46
+ parent.uuid = parent_uuid
47
+ end
43
48
 
44
49
  ProcessMetrics.measure(process_name, parent) do |metric|
45
50
  ProcessMetrics.config.logger.debug "About to send #{raw_method_name} with args #{args.inspect} and block #{block.inspect} to #{self}"
51
+ metric.uuid = uuid if uuid
46
52
  metric.data = {args: args, block: block}
47
53
 
48
54
  send(raw_method_name, *args, &block)
@@ -73,18 +79,18 @@ module ProcessMetrics
73
79
  base.extend ProcessMetrics::ClassMethods
74
80
  end
75
81
 
76
- def parent_uuid(options)
77
- return unless options
82
+ def extract_option(options, option_name)
83
+ return unless options && options[option_name]
78
84
 
79
- if options[:parent_uuid].respond_to?(:call)
85
+ if options[option_name].respond_to?(:call)
80
86
  # It's a proc. parent_uuid is the return value
81
- options[:parent_uuid].call(self)
82
- elsif options[:parent_uuid].is_a?(Symbol)
87
+ options[option_name].call(self)
88
+ elsif options[option_name].is_a?(Symbol)
83
89
  # It's a symbol. Call method on object and parent_uuid is its result.
84
- send(options[:parent_uuid])
90
+ send(options[option_name])
85
91
  else
86
92
  # It's something static. Just call #to_s
87
- options[:parent_uuid].to_s
93
+ options[option_name].to_s
88
94
  end
89
95
  end
90
96
  end
@@ -1,3 +1,3 @@
1
1
  module ProcessMetrics
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.11"
3
3
  end
metadata CHANGED
@@ -1,73 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: process_metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Uyezu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-01 00:00:00.000000000 Z
11
+ date: 2014-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.0'
20
- - - '>='
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: 2.0.5
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ~>
27
+ - - "~>"
28
28
  - !ruby/object:Gem::Version
29
29
  version: '2.0'
30
- - - '>='
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 2.0.5
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: pry-debugger
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ~>
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0.2'
40
- - - '>='
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: 0.2.2
43
43
  type: :development
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ~>
47
+ - - "~>"
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0.2'
50
- - - '>='
50
+ - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: 0.2.2
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: minitest
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - ~>
57
+ - - "~>"
58
58
  - !ruby/object:Gem::Version
59
59
  version: '5.3'
60
- - - '>='
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: 5.3.1
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ~>
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '5.3'
70
- - - '>='
70
+ - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: 5.3.1
73
73
  description: A gem that provides utilities to measure a process and its sub tasks.
@@ -92,22 +92,22 @@ licenses:
92
92
  metadata: {}
93
93
  post_install_message:
94
94
  rdoc_options:
95
- - --charset=UTF-8
95
+ - "--charset=UTF-8"
96
96
  require_paths:
97
97
  - lib
98
98
  required_ruby_version: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - '>='
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  requirements:
105
- - - '>='
105
+ - - ">="
106
106
  - !ruby/object:Gem::Version
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.0.14
110
+ rubygems_version: 2.2.2
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: Process metrics