google-cloud-debugger 0.26.1 → 0.27.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -34,14 +34,6 @@ module Google
34
34
  # @return [Google::Cloud::Debugger::Agent]
35
35
  attr_reader :agent
36
36
 
37
- ##
38
- # Ruby application root directory, in absolute path form. The
39
- # Stackdriver Debugger Service only knows the relative application file
40
- # path. So the tracer needs to combine relative file path with
41
- # application root directory to get full file path for tracing purpose
42
- # @return [String]
43
- attr_accessor :app_root
44
-
45
37
  ##
46
38
  # @private File tracing point that enables line tracing when program
47
39
  # counter enters a file that contains breakpoints
@@ -67,16 +59,11 @@ module Google
67
59
 
68
60
  ##
69
61
  # @private Construct a new instance of Tracer
70
- def initialize agent, app_root: nil
62
+ def initialize agent
71
63
  @agent = agent
72
64
  @file_tracepoint = nil
73
65
  @fiber_tracepoint = nil
74
66
  @breakpoints_cache = {}
75
-
76
- @app_root = app_root
77
- @app_root ||= Rack::Directory.new("").root if defined? Rack::Directory
78
-
79
- fail "Unable to determine application root path" unless @app_root
80
67
  end
81
68
 
82
69
  ##
@@ -90,7 +77,7 @@ module Google
90
77
 
91
78
  active_breakpoints.each do |active_breakpoint|
92
79
  breakpoint_line = active_breakpoint.line
93
- breakpoint_path = full_breakpoint_path active_breakpoint.path
80
+ breakpoint_path = active_breakpoint.full_path
94
81
  breakpoints_hash[breakpoint_path] ||= {}
95
82
  breakpoints_hash[breakpoint_path][breakpoint_line] ||= []
96
83
  breakpoints_hash[breakpoint_path][breakpoint_line].push(
@@ -103,14 +90,26 @@ module Google
103
90
  end
104
91
 
105
92
  ##
106
- # Callback function when a breakpoint is hit. Handover the hit
93
+ # Callback function when a set of breakpoints are hit. Handover the hit
107
94
  # breakpoint to breakpoint_manager to be evaluated.
108
- #
109
- def breakpoint_hit breakpoint, call_stack_bindings
110
- return if breakpoint.nil? || breakpoint.complete?
95
+ def breakpoints_hit breakpoints, call_stack_bindings
96
+ breakpoints.each do |breakpoint|
97
+ # Stop evaluating breakpoints if we have quotas and the quotas are
98
+ # met.
99
+ break if agent.quota_manager && !agent.quota_manager.more?
100
+
101
+ next if breakpoint.nil? || breakpoint.complete?
102
+
103
+ time_begin = Time.now
111
104
 
112
- agent.breakpoint_manager.breakpoint_hit breakpoint,
113
- call_stack_bindings
105
+ agent.breakpoint_manager.breakpoint_hit breakpoint,
106
+ call_stack_bindings
107
+
108
+ # Report time and resource consumption to quota manager
109
+ if agent.quota_manager.respond_to? :consume
110
+ agent.quota_manager.consume time: Time.now - time_begin
111
+ end
112
+ end
114
113
 
115
114
  update_breakpoints_cache
116
115
 
@@ -118,17 +117,6 @@ module Google
118
117
  disable_traces if @breakpoints_cache.empty?
119
118
  end
120
119
 
121
- ##
122
- # @private Covert breakpoint's relative file path to absolute file
123
- # path by combining it with application root directory path.
124
- def full_breakpoint_path breakpoint_path
125
- if app_root.nil? || app_root.empty?
126
- breakpoint_path
127
- else
128
- "#{app_root}/#{breakpoint_path}"
129
- end
130
- end
131
-
132
120
  ##
133
121
  # Get the sync the breakpoints cache with BreakpointManager. Start
134
122
  # tracing and monitoring if there are any breakpoints.
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Debugger
19
- VERSION = "0.26.1"
19
+ VERSION = "0.27.0"
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-debugger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.1
4
+ version: 0.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heng Xiong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-12 00:00:00.000000000 Z
11
+ date: 2017-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: binding_of_caller
@@ -273,15 +273,21 @@ files:
273
273
  - lib/google/cloud/debugger/breakpoint/evaluator.rb
274
274
  - lib/google/cloud/debugger/breakpoint/source_location.rb
275
275
  - lib/google/cloud/debugger/breakpoint/stack_frame.rb
276
+ - lib/google/cloud/debugger/breakpoint/status_message.rb
277
+ - lib/google/cloud/debugger/breakpoint/validator.rb
276
278
  - lib/google/cloud/debugger/breakpoint/variable.rb
279
+ - lib/google/cloud/debugger/breakpoint/variable_table.rb
277
280
  - lib/google/cloud/debugger/breakpoint_manager.rb
278
281
  - lib/google/cloud/debugger/credentials.rb
279
282
  - lib/google/cloud/debugger/debuggee.rb
280
283
  - lib/google/cloud/debugger/debuggee/app_uniquifier_generator.rb
284
+ - lib/google/cloud/debugger/logpoint.rb
281
285
  - lib/google/cloud/debugger/middleware.rb
282
286
  - lib/google/cloud/debugger/project.rb
283
287
  - lib/google/cloud/debugger/rails.rb
288
+ - lib/google/cloud/debugger/request_quota_manager.rb
284
289
  - lib/google/cloud/debugger/service.rb
290
+ - lib/google/cloud/debugger/snappoint.rb
285
291
  - lib/google/cloud/debugger/tracer.rb
286
292
  - lib/google/cloud/debugger/transmitter.rb
287
293
  - lib/google/cloud/debugger/v2.rb