google-cloud-debugger 0.24.1 → 0.25.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 +4 -4
- data/README.md +1 -1
- data/lib/google/cloud/debugger.rb +28 -0
- data/lib/google/cloud/debugger/middleware.rb +54 -15
- data/lib/google/cloud/debugger/rails.rb +76 -75
- data/lib/google/cloud/debugger/version.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 123026733717c135b469d6151982edc6b0cd8f24
|
4
|
+
data.tar.gz: 0ee45f3037ad8503a1b05dd08274e207e580d6dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 555b2972eb3db4112e4cb51c2a0f72adfc1c058f9519ffa31fd8d367280db39e91a9be14c10a07b9fd7d3b73c1e37c29f81fee13e66ddd1e7b68311568ef328b
|
7
|
+
data.tar.gz: 7c7780ab4ffd74371586bb256cd4c22094af3b2b2d5a9bdebbbb36ff8c2c49c7abe97f5bf687448869409d8a07a4d312e61370f7b03d2ae07fdf905f9cbaf792
|
data/README.md
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
|
16
16
|
require "google-cloud-debugger"
|
17
17
|
require "google/cloud/debugger/project"
|
18
|
+
require "stackdriver/core"
|
18
19
|
|
19
20
|
module Google
|
20
21
|
module Cloud
|
@@ -319,6 +320,16 @@ module Google
|
|
319
320
|
# See {Google::Cloud::Debugger::V2::Debugger2Client} for details.
|
320
321
|
#
|
321
322
|
module Debugger
|
323
|
+
# Initialize :error_reporting as a nested Configuration under
|
324
|
+
# Google::Cloud if haven't already
|
325
|
+
unless Google::Cloud.configure.option? :debugger
|
326
|
+
Google::Cloud.configure.add_options :debugger
|
327
|
+
|
328
|
+
Google::Cloud.configure.define_singleton_method :debugger do
|
329
|
+
Google::Cloud.configure[:debugger]
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
322
333
|
##
|
323
334
|
# Creates a new debugger object for instrumenting Stackdriver Debugger for
|
324
335
|
# an application. Each call creates a new debugger agent with independent
|
@@ -374,6 +385,23 @@ module Google
|
|
374
385
|
module_version: module_version
|
375
386
|
)
|
376
387
|
end
|
388
|
+
|
389
|
+
|
390
|
+
##
|
391
|
+
# Configure the Stackdriver Debugger agent.
|
392
|
+
#
|
393
|
+
# See the [Configuration
|
394
|
+
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/stackdriver/guides/instrumentation_configuration)
|
395
|
+
# for full configuration parameters.
|
396
|
+
#
|
397
|
+
# @return [Stackdriver::Core::Configuration] The configuration object
|
398
|
+
# the Google::Cloud::ErrorReporting module uses.
|
399
|
+
#
|
400
|
+
def self.configure
|
401
|
+
yield Google::Cloud.configure[:debugger] if block_given?
|
402
|
+
|
403
|
+
Google::Cloud.configure[:debugger]
|
404
|
+
end
|
377
405
|
end
|
378
406
|
end
|
379
407
|
end
|
@@ -29,26 +29,25 @@ module Google
|
|
29
29
|
# @param [Google::Cloud::Debugger::Project] debugger A debugger to be
|
30
30
|
# used by this middleware. If not given, will construct a new one
|
31
31
|
# using the other parameters.
|
32
|
-
# @param [
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
# a debugger is given.
|
37
|
-
# @param [String] module_name Name for the debuggee application.
|
38
|
-
# Optional if a debugger is given.
|
39
|
-
# @param [String] module_version Version identifier for the debuggee
|
40
|
-
# application. Optiona if a debugger is given.
|
32
|
+
# @param [Hash] *kwargs Hash of configuration settings. Used for
|
33
|
+
# backward API compatibility. See the [Configuration
|
34
|
+
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/stackdriver/guides/instrumentation_configuration)
|
35
|
+
# for the prefered way to set configuration parameters.
|
41
36
|
#
|
42
37
|
# @return [Google::Cloud::Debugger::Middleware] A new
|
43
38
|
# Google::Cloud::Debugger::Middleware instance
|
44
39
|
#
|
45
|
-
def initialize app, debugger: nil,
|
46
|
-
project: nil, keyfile: nil
|
40
|
+
def initialize app, debugger: nil, **kwargs
|
47
41
|
@app = app
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
42
|
+
|
43
|
+
load_config kwargs
|
44
|
+
|
45
|
+
@debugger = debugger ||
|
46
|
+
Debugger.new(project: configuration.project_id,
|
47
|
+
keyfile: configuration.keyfile,
|
48
|
+
module_name: configuration.module_name,
|
49
|
+
module_version: configuration.module_version)
|
50
|
+
# Immediately start the debugger agent
|
52
51
|
@debugger.start
|
53
52
|
end
|
54
53
|
|
@@ -71,6 +70,46 @@ module Google
|
|
71
70
|
# Stop breakpoints tracing beyond this point
|
72
71
|
@debugger.agent.tracer.disable_traces_for_thread
|
73
72
|
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
##
|
77
|
+
# Consolidate configurations from various sources. Also set
|
78
|
+
# instrumentation config parameters to default values if not set
|
79
|
+
# already.
|
80
|
+
#
|
81
|
+
def load_config **kwargs
|
82
|
+
configuration.project_id = kwargs[:project] ||
|
83
|
+
kwargs[:project_id] ||
|
84
|
+
configuration.project_id
|
85
|
+
configuration.keyfile = kwargs[:keyfile] ||
|
86
|
+
configuration.keyfile
|
87
|
+
|
88
|
+
configuration.module_name = kwargs[:module_name] ||
|
89
|
+
configuration.module_name
|
90
|
+
configuration.module_version = kwargs[:module_version] ||
|
91
|
+
configuration.module_version
|
92
|
+
|
93
|
+
init_default_config
|
94
|
+
end
|
95
|
+
|
96
|
+
##
|
97
|
+
# Fallback to default configuration values if not defined already
|
98
|
+
def init_default_config
|
99
|
+
configuration.project_id ||= Cloud.configure.project_id ||
|
100
|
+
Debugger::Project.default_project
|
101
|
+
configuration.keyfile ||= Cloud.configure.keyfile
|
102
|
+
|
103
|
+
configuration.module_name ||= Debugger::Project.default_module_name
|
104
|
+
configuration.module_version ||=
|
105
|
+
Debugger::Project.default_module_version
|
106
|
+
end
|
107
|
+
|
108
|
+
##
|
109
|
+
# @private Get Google::Cloud::Debugger.configure
|
110
|
+
def configuration
|
111
|
+
Google::Cloud::Debugger.configure
|
112
|
+
end
|
74
113
|
end
|
75
114
|
end
|
76
115
|
end
|
@@ -31,23 +31,9 @@ module Google
|
|
31
31
|
# to the application code.
|
32
32
|
#
|
33
33
|
# The Railtie should also initialize a debugger to be used by the
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
# # Explicitly enable or disable Stackdriver Debugger Agent
|
38
|
-
# config.google_cloud.use_debugger = true
|
39
|
-
# # Shared Google Cloud Platform project identifier
|
40
|
-
# config.google_cloud.project_id = "gcloud-project"
|
41
|
-
# # Google Cloud Platform project identifier for Stackdriver Debugger
|
42
|
-
# config.google_cloud.debugger.project_id = "debugger-project"
|
43
|
-
# # Share Google Cloud authentication json file
|
44
|
-
# config.google_cloud.keyfile = "/path/to/keyfile.json"
|
45
|
-
# # Google Cloud authentication json file for Stackdriver Debugger only
|
46
|
-
# config.google_cloud.debugger.keyfile = "/path/to/keyfile.json"
|
47
|
-
# # Stackdriver Debugger Agent module name identifier
|
48
|
-
# config.google_cloud.debugger.module_name = "my-ruby-app"
|
49
|
-
# # Stackdriver Debugger Agent module version identifier
|
50
|
-
# config.google_cloud.debugger.module_version = "v1"
|
34
|
+
# Middleware. See the [Configuration
|
35
|
+
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/stackdriver/guides/instrumentation_configuration)
|
36
|
+
# on how to configure the Railtie and Middleware.
|
51
37
|
#
|
52
38
|
class Railtie < ::Rails::Railtie
|
53
39
|
config.google_cloud = ::ActiveSupport::OrderedOptions.new unless
|
@@ -58,84 +44,99 @@ module Google
|
|
58
44
|
end
|
59
45
|
|
60
46
|
initializer "Stackdriver.Debugger" do |app|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
project_id = debugger_config[:project_id]
|
65
|
-
keyfile = debugger_config[:keyfile]
|
66
|
-
module_name = debugger_config[:module_name]
|
67
|
-
module_version = debugger_config[:module_version]
|
68
|
-
|
69
|
-
debugger =
|
70
|
-
Google::Cloud::Debugger.new project: project_id,
|
71
|
-
keyfile: keyfile,
|
72
|
-
module_name: module_name,
|
73
|
-
module_version: module_version
|
74
|
-
|
75
|
-
app.middleware.insert_after Rack::ETag,
|
76
|
-
Google::Cloud::Debugger::Middleware,
|
77
|
-
debugger: debugger
|
78
|
-
end
|
47
|
+
self.class.consolidate_rails_config app.config
|
48
|
+
|
49
|
+
self.class.init_middleware app if Cloud.configure.use_debugger
|
79
50
|
end
|
80
51
|
|
81
52
|
##
|
82
|
-
#
|
83
|
-
#
|
84
|
-
|
85
|
-
|
86
|
-
|
53
|
+
# @private Init Debugger integration for Rails. Setup configuration and
|
54
|
+
# insert the Middleware.
|
55
|
+
def self.init_middleware app
|
56
|
+
app.middleware.insert_after Rack::ETag,
|
57
|
+
Google::Cloud::Debugger::Middleware
|
58
|
+
end
|
59
|
+
|
60
|
+
##
|
61
|
+
# @private Consolidate Rails configuration into Debugger instrumentation
|
62
|
+
# configuration. Also consolidate the `use_debugger` setting by
|
63
|
+
# verifying credentials and Rails environment. The `use_debugger`
|
64
|
+
# setting will be true if credentials are valid, and the setting is
|
65
|
+
# manually set to true or Rails is in production environment.
|
87
66
|
#
|
88
67
|
# @param [Rails::Railtie::Configuration] config The
|
89
68
|
# Rails.application.config
|
90
69
|
#
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
70
|
+
def self.consolidate_rails_config config
|
71
|
+
merge_rails_config config
|
72
|
+
|
73
|
+
init_default_config
|
74
|
+
|
75
|
+
# Done if Google::Cloud.configure.use_debugger is explicitly
|
76
|
+
# false
|
77
|
+
return if Google::Cloud.configure.use_debugger == false
|
95
78
|
|
96
|
-
#
|
97
|
-
|
98
|
-
|
79
|
+
# Verify credentials and set use_debugger to false if
|
80
|
+
# credentials are invalid
|
81
|
+
unless valid_credentials? Debugger.configure.project_id,
|
82
|
+
Debugger.configure.keyfile
|
83
|
+
Cloud.configure.use_debugger = false
|
84
|
+
return
|
85
|
+
end
|
86
|
+
|
87
|
+
# Otherwise set use_debugger to true if Rails is running in
|
88
|
+
# production
|
89
|
+
Google::Cloud.configure.use_debugger ||= Rails.env.production?
|
90
|
+
end
|
99
91
|
|
100
|
-
|
101
|
-
|
92
|
+
##
|
93
|
+
# @private Merge Rails configuration into Debugger instrumentation
|
94
|
+
# configuration.
|
95
|
+
def self.merge_rails_config rails_config
|
96
|
+
gcp_config = rails_config.google_cloud
|
97
|
+
dbg_config = gcp_config.debugger
|
98
|
+
|
99
|
+
Cloud.configure.use_debugger ||= gcp_config.use_debugger
|
100
|
+
Debugger.configure do |config|
|
101
|
+
config.project_id ||= dbg_config.project_id || gcp_config.project_id
|
102
|
+
config.keyfile ||= dbg_config.keyfile || gcp_config.keyfile
|
103
|
+
config.module_name ||= dbg_config.module_name
|
104
|
+
config.module_version ||= dbg_config.module_version
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
##
|
109
|
+
# Fallback to default config values if config parameters not provided.
|
110
|
+
def self.init_default_config
|
111
|
+
config = Debugger.configure
|
112
|
+
config.project_id ||= Debugger::Project.default_project
|
113
|
+
config.module_name ||= Debugger::Project.default_module_name
|
114
|
+
config.module_version ||= Debugger::Project.default_module_version
|
115
|
+
end
|
116
|
+
|
117
|
+
##
|
118
|
+
# @private Verify credentials
|
119
|
+
def self.valid_credentials? project_id, keyfile
|
102
120
|
begin
|
103
|
-
|
104
|
-
debugger_config[:keyfile])
|
121
|
+
Debugger::Credentials.credentials_with_scope keyfile
|
105
122
|
rescue => e
|
106
|
-
|
107
|
-
"to
|
123
|
+
STDOUT.puts "Note: Google::Cloud::Debugger is disabled because " \
|
124
|
+
"it failed to authorize with the service. (#{e.message})"
|
108
125
|
return false
|
109
126
|
end
|
110
127
|
|
111
|
-
project_id = debugger_config[:project_id] ||
|
112
|
-
Google::Cloud::Debugger::Project.default_project
|
113
128
|
if project_id.to_s.empty?
|
114
|
-
|
115
|
-
"
|
129
|
+
STDOUT.puts "Note: Google::Cloud::Debugger is disabled because " \
|
130
|
+
"the project ID could not be determined."
|
116
131
|
return false
|
117
132
|
end
|
118
133
|
|
119
|
-
|
120
|
-
# config.stackdriver.use_debugger is true
|
121
|
-
Rails.env.production? || use_debugger
|
134
|
+
true
|
122
135
|
end
|
123
136
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
gcp_config = config.google_cloud
|
128
|
-
debugger_config = gcp_config[:debugger]
|
129
|
-
use_debugger =
|
130
|
-
gcp_config.key?(:use_debugger) ? gcp_config.use_debugger : nil
|
131
|
-
{
|
132
|
-
project_id: debugger_config.project_id || gcp_config.project_id,
|
133
|
-
keyfile: debugger_config.keyfile || gcp_config.keyfile,
|
134
|
-
module_name: debugger_config.module_name,
|
135
|
-
module_version: debugger_config.module_version,
|
136
|
-
use_debugger: use_debugger
|
137
|
-
}
|
138
|
-
end
|
137
|
+
private_class_method :merge_rails_config,
|
138
|
+
:init_default_config,
|
139
|
+
:valid_credentials?
|
139
140
|
end
|
140
141
|
end
|
141
142
|
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.
|
4
|
+
version: 0.25.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-
|
11
|
+
date: 2017-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: binding_of_caller
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.8.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: stackdriver-core
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.1'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: minitest
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -273,7 +287,7 @@ files:
|
|
273
287
|
- lib/google/devtools/clouddebugger/v2/debugger_pb.rb
|
274
288
|
- lib/google/devtools/clouddebugger/v2/debugger_services_pb.rb
|
275
289
|
- lib/google/devtools/source/v1/source_context_pb.rb
|
276
|
-
homepage:
|
290
|
+
homepage: https://github.com/GoogleCloudPlatform/google-cloud-ruby/tree/master/google-cloud-debugger
|
277
291
|
licenses:
|
278
292
|
- Apache-2.0
|
279
293
|
metadata: {}
|
@@ -293,7 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
293
307
|
version: '0'
|
294
308
|
requirements: []
|
295
309
|
rubyforge_project:
|
296
|
-
rubygems_version: 2.6.
|
310
|
+
rubygems_version: 2.6.12
|
297
311
|
signing_key:
|
298
312
|
specification_version: 4
|
299
313
|
summary: API Client and instrumentation library for Stackdriver Debugger
|