fiveruns-dash-ruby 0.7.3 → 0.7.4

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.
@@ -36,7 +36,7 @@ module Fiveruns::Dash
36
36
  end
37
37
  end
38
38
 
39
- def self.reentrant_timing(token, offset, this, args)
39
+ def self.reentrant_timing(token, offset, this, limit_to_within, args)
40
40
  # token allows us to handle re-entrant timing, see e.g. ar_time
41
41
  Thread.current[token] = 0 if Thread.current[token].nil?
42
42
  Thread.current[token] = Thread.current[token] + 1
@@ -47,19 +47,29 @@ module Fiveruns::Dash
47
47
  time = Time.now - start
48
48
  Thread.current[token] = Thread.current[token] - 1
49
49
  if Thread.current[token] == 0
50
- ::Fiveruns::Dash::Instrument.handlers[offset].call(this, time, *args)
50
+ if !limit_to_within || (Thread.current[:dash_markers] || []).include?(limit_to_within)
51
+ ::Fiveruns::Dash::Instrument.handlers[offset].call(this, time, *args)
52
+ end
51
53
  end
52
54
  end
53
55
  result
54
56
  end
55
57
 
56
- def self.timing(offset, this, args)
58
+ def self.timing(offset, this, args, mark, limit_to_within)
59
+ if mark
60
+ Thread.current[:dash_markers] ||= []
61
+ Thread.current[:dash_markers].push mark
62
+ end
57
63
  start = Time.now
58
64
  begin
59
65
  result = yield
60
66
  ensure
61
67
  time = Time.now - start
62
- ::Fiveruns::Dash::Instrument.handlers[offset].call(this, time, *args)
68
+ Thread.current[:dash_markers].pop if mark
69
+
70
+ if !limit_to_within || (Thread.current[:dash_markers] || []).include?(limit_to_within)
71
+ ::Fiveruns::Dash::Instrument.handlers[offset].call(this, time, *args)
72
+ end
63
73
  end
64
74
  result
65
75
  end
@@ -85,13 +95,13 @@ module Fiveruns::Dash
85
95
  EXCEPTIONS
86
96
  elsif options[:reentrant_token]
87
97
  <<-REENTRANT
88
- ::Fiveruns::Dash::Instrument.reentrant_timing(:id#{options[:reentrant_token]}, #{offset}, self, args) do
98
+ ::Fiveruns::Dash::Instrument.reentrant_timing(:id#{options[:reentrant_token]}, #{offset}, self, #{options[:only_within] ? ":#{options[:only_within]}" : 'nil'}, args) do
89
99
  #{without}(*args, &block)
90
100
  end
91
101
  REENTRANT
92
102
  else
93
103
  <<-PERFORMANCE
94
- ::Fiveruns::Dash::Instrument.timing(#{offset}, self, args) do
104
+ ::Fiveruns::Dash::Instrument.timing(#{offset}, self, args, #{options[:mark_as] ? ":#{options[:mark_as]}" : 'nil'}, #{options[:only_within] ? ":#{options[:only_within]}" : 'nil'}) do
95
105
  #{without}(*args, &block)
96
106
  end
97
107
  PERFORMANCE
@@ -164,12 +164,12 @@ module Fiveruns::Dash
164
164
  bad_value! "Contexts must have an even number of items"
165
165
  end
166
166
  else
167
- bad_value! "Unknown context type"
167
+ bad_value! "Unknown context type: #{key.class.name}"
168
168
  end
169
169
  all
170
170
  end
171
171
  else
172
- bad_value! "Unknown value type"
172
+ bad_value! "Unknown value type: #{value.class.name}"
173
173
  end
174
174
  end
175
175
 
@@ -268,6 +268,8 @@ module Fiveruns::Dash
268
268
  def instrument_options
269
269
  returning({}) do |options|
270
270
  options[:reentrant_token] = self.object_id.abs if @options[:reentrant]
271
+ options[:only_within] = @options[:only_within] if @options[:only_within]
272
+ options[:mark_as] = @name if @options[:mark]
271
273
  end
272
274
  end
273
275
 
data/version.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 7
4
- :patch: 3
4
+ :patch: 4
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fiveruns-dash-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - FiveRuns Development Team
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-02 00:00:00 -08:00
12
+ date: 2009-02-09 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency