google-cloud-debugger 0.31.0 → 0.32.0

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
  SHA256:
3
- metadata.gz: 71f28cd2cdbb26aeb952111ceed9989d726fe066c7b42b15dc6abc01b77c6d80
4
- data.tar.gz: 212961fe1b440ca8934468eedc899ce0304523443944fd4e882e7d07bca60157
3
+ metadata.gz: 192b49269ab919dffd129a0ec48af66cdab93f4c83cf4e502e14dfedeceaab80
4
+ data.tar.gz: 0c88a6443ae79182cee72c5cff5c6fc2fc0641fe1424ec30fba0d498c653f508
5
5
  SHA512:
6
- metadata.gz: 557129ab5d5b4010df8d7ff0baebe95fe3b20ea5615c2b50e542db0da479c14be7f8ec49e2e72bbfe0eb25d65ca630204f0097657fe26bf7d5e24b08cdc14ab4
7
- data.tar.gz: e87fece9e975bd6b6a194029b880d6a682890af4df8c866b0424bed021744e689752a9454ef824ed26b2cebbb1d07157c8422c3718fbd123dc83997bcc729cf6
6
+ metadata.gz: 876816208a7431ec0201a85cdf5ff1c861a2b7fa7f2beb64be8ae96224b00ddcdcbb9de1b92d0c47970b0f0ac83c82edbfec3c93edb8344d1b9667340b7d6791
7
+ data.tar.gz: aae912a8b8d3d6a6133a3731bf0c5aa6c8c3b4d82a2c7c8840f76d779477d9365fbad56f5bec27a15adb455ca33c6b49f56a0aec4ebd5169e79fb102c7a5cafb
data/README.md CHANGED
@@ -226,6 +226,13 @@ for a list of possible configuration options.
226
226
 
227
227
  This library is supported on Ruby 2.2 or later.
228
228
 
229
+ However, Ruby 2.3 or later is strongly recommended, as earlier releases have
230
+ reached or are nearing end-of-life. After June 1, 2018, Google will provide
231
+ official support only for Ruby versions that are considered current and
232
+ supported by Ruby Core (that is, Ruby versions that are either in normal
233
+ maintenance or in security maintenance).
234
+ See https://www.ruby-lang.org/en/downloads/branches/ for further details.
235
+
229
236
  This library follows [Semantic Versioning](http://semver.org/). It is currently
230
237
  in major version zero (0.y.z), which means that anything may change at any time
231
238
  and the public API should not be considered stable.
@@ -13,6 +13,8 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
+ require "set"
17
+
16
18
  require "google/cloud/logging/logger"
17
19
  require "google/cloud/debugger/request_quota_manager"
18
20
 
@@ -23,8 +25,71 @@ module Google
23
25
  # Rack Middleware implementation that supports Stackdriver Debugger Agent
24
26
  # in Rack-based Ruby frameworks. It instantiates a new debugger agent if
25
27
  # one isn't given already. It helps optimize Debugger Agent Tracer
26
- # performance by suspend and resume tracer between each request.
28
+ # performance by suspending and resuming the tracer between each request.
29
+ #
30
+ # To use this middleware, simply install it in your Rack configuration.
31
+ # The middleware will take care of registering itself with the
32
+ # Stackdriver Debugger and activating the debugger agent. The location
33
+ # of the middleware in the middleware stack matters: breakpoints will be
34
+ # detected in middleware appearing after but not before this middleware.
35
+ #
36
+ # For best results, you should also call {Middleware.start_agents}
37
+ # during application initialization. See its documentation for details.
38
+ #
27
39
  class Middleware
40
+ ##
41
+ # Reset deferred start mechanism.
42
+ # @private
43
+ #
44
+ def self.reset_deferred_start
45
+ @debuggers_to_start = Set.new
46
+ end
47
+
48
+ reset_deferred_start
49
+
50
+ ##
51
+ # Start the debugger. Either adds it to the deferred list, or, if the
52
+ # deferred list has already been started, starts immediately.
53
+ #
54
+ # @param [Google::Cloud::Debugger::Project] debugger
55
+ #
56
+ # @private
57
+ #
58
+ def self.deferred_start debugger
59
+ if @debuggers_to_start
60
+ @debuggers_to_start << debugger
61
+ else
62
+ debugger.start
63
+ end
64
+ end
65
+
66
+ ##
67
+ # This should be called once the application determines that it is safe
68
+ # to start background threads and open gRPC connections. It informs
69
+ # the middleware system that it can start debugger agents.
70
+ #
71
+ # Generally, this matters if the application forks worker processes;
72
+ # this method should be called only after workers are forked, since
73
+ # threads and network connections interact badly with fork. For
74
+ # example, when running Puma in
75
+ # [clustered mode](https://github.com/puma/puma#clustered-mode), this
76
+ # method should be called in an `on_worker_boot` block.
77
+ #
78
+ # If the application does no forking, this method can be called any
79
+ # time early in the application initialization process.
80
+ #
81
+ # If {Middleware.start_agents} is never called, the debugger agent will
82
+ # be started when the first request is received. This should be safe,
83
+ # but it will probably mean breakpoints will not be recognized during
84
+ # that first request. For best results, an application should call this
85
+ # method at the appropriate time.
86
+ #
87
+ def self.start_agents
88
+ return unless @debuggers_to_start
89
+ @debuggers_to_start.each(&:start)
90
+ @debuggers_to_start = nil
91
+ end
92
+
28
93
  ##
29
94
  # Create a new Debugger Middleware.
30
95
  #
@@ -58,8 +123,7 @@ module Google
58
123
  Google::Cloud::Debugger::RequestQuotaManager.new
59
124
  end
60
125
 
61
- # Immediately start the debugger agent
62
- @debugger.start
126
+ Middleware.deferred_start(@debugger)
63
127
  end
64
128
 
65
129
  ##
@@ -73,6 +137,9 @@ module Google
73
137
  # @return [Rack::Response] The response from downstream Rack app
74
138
  #
75
139
  def call env
140
+ # Ensure the agent is running. (Note the start method is idempotent.)
141
+ @debugger.start
142
+
76
143
  # Enable/resume breakpoints tracing
77
144
  @debugger.agent.tracer.start
78
145
 
@@ -37,6 +37,15 @@ module Google
37
37
  # on how to configure the Railtie and Middleware.
38
38
  #
39
39
  class Railtie < ::Rails::Railtie
40
+ ##
41
+ # Inform the Railtie that it is safe to start debugger agents.
42
+ # This simply calls {Google::Cloud::Debugger::Middleware.start_agents}.
43
+ # See its documentation for more information.
44
+ #
45
+ def self.start_agents
46
+ Google::Cloud::Debugger::Middleware.start_agents
47
+ end
48
+
40
49
  config.google_cloud = ::ActiveSupport::OrderedOptions.new unless
41
50
  config.respond_to? :google_cloud
42
51
  config.google_cloud[:debugger] = ::ActiveSupport::OrderedOptions.new
@@ -87,7 +96,7 @@ module Google
87
96
 
88
97
  # Otherwise set use_debugger to true if Rails is running in
89
98
  # the production environment
90
- Google::Cloud.configure.use_debugger ||= Rails.env.production?
99
+ Google::Cloud.configure.use_debugger ||= ::Rails.env.production?
91
100
  end
92
101
 
93
102
  # rubocop:disable all
@@ -17,7 +17,7 @@ module Google
17
17
  # rubocop:disable LineLength
18
18
 
19
19
  ##
20
- # # Ruby Client for Stackdriver Debugger API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
20
+ # # Ruby Client for Stackdriver Debugger API ([Beta](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
21
21
  #
22
22
  # [Stackdriver Debugger API][Product Documentation]:
23
23
  # Examines the call stack and variables of a running application
@@ -51,4 +51,4 @@ module Google
51
51
  end
52
52
  end
53
53
  end
54
- end
54
+ end
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Debugger
19
- VERSION = "0.31.0".freeze
19
+ VERSION = "0.32.0".freeze
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.31.0
4
+ version: 0.32.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: 2018-02-27 00:00:00.000000000 Z
11
+ date: 2018-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: binding_of_caller
@@ -328,7 +328,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
328
328
  version: '0'
329
329
  requirements: []
330
330
  rubyforge_project:
331
- rubygems_version: 2.7.6
331
+ rubygems_version: 2.7.7
332
332
  signing_key:
333
333
  specification_version: 4
334
334
  summary: API Client and instrumentation library for Stackdriver Debugger