google-cloud-debugger 0.35.2 → 0.40.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +2 -1
  3. data/CHANGELOG.md +47 -0
  4. data/OVERVIEW.md +28 -59
  5. data/TROUBLESHOOTING.md +2 -8
  6. data/ext/google/cloud/debugger/debugger_c/tracer.c +8 -33
  7. data/lib/google-cloud-debugger.rb +13 -15
  8. data/lib/google/cloud/debugger.rb +18 -16
  9. data/lib/google/cloud/debugger/breakpoint.rb +8 -8
  10. data/lib/google/cloud/debugger/breakpoint/evaluator.rb +1 -1
  11. data/lib/google/cloud/debugger/breakpoint/source_location.rb +3 -3
  12. data/lib/google/cloud/debugger/breakpoint/stack_frame.rb +5 -5
  13. data/lib/google/cloud/debugger/breakpoint/status_message.rb +4 -6
  14. data/lib/google/cloud/debugger/breakpoint/variable.rb +5 -5
  15. data/lib/google/cloud/debugger/credentials.rb +9 -6
  16. data/lib/google/cloud/debugger/debuggee.rb +4 -4
  17. data/lib/google/cloud/debugger/service.rb +25 -66
  18. data/lib/google/cloud/debugger/version.rb +1 -1
  19. metadata +12 -70
  20. data/lib/google/cloud/debugger/v2.rb +0 -243
  21. data/lib/google/cloud/debugger/v2/controller2_client.rb +0 -370
  22. data/lib/google/cloud/debugger/v2/controller2_client_config.json +0 -41
  23. data/lib/google/cloud/debugger/v2/credentials.rb +0 -42
  24. data/lib/google/cloud/debugger/v2/debugger2_client.rb +0 -478
  25. data/lib/google/cloud/debugger/v2/debugger2_client_config.json +0 -51
  26. data/lib/google/cloud/debugger/v2/doc/google/devtools/clouddebugger/v2/controller.rb +0 -91
  27. data/lib/google/cloud/debugger/v2/doc/google/devtools/clouddebugger/v2/data.rb +0 -443
  28. data/lib/google/cloud/debugger/v2/doc/google/devtools/clouddebugger/v2/debugger.rb +0 -151
  29. data/lib/google/cloud/debugger/v2/doc/google/devtools/source/v1/source_context.rb +0 -162
  30. data/lib/google/cloud/debugger/v2/doc/google/protobuf/empty.rb +0 -29
  31. data/lib/google/cloud/debugger/v2/doc/google/protobuf/timestamp.rb +0 -113
  32. data/lib/google/devtools/clouddebugger/v2/controller_pb.rb +0 -50
  33. data/lib/google/devtools/clouddebugger/v2/controller_services_pb.rb +0 -98
  34. data/lib/google/devtools/clouddebugger/v2/data_pb.rb +0 -108
  35. data/lib/google/devtools/clouddebugger/v2/debugger_pb.rb +0 -77
  36. data/lib/google/devtools/clouddebugger/v2/debugger_services_pb.rb +0 -66
  37. data/lib/google/devtools/source/v1/source_context_pb.rb +0 -90
@@ -67,8 +67,6 @@ module Google
67
67
  # * `https://www.googleapis.com/auth/logging.admin`
68
68
  #
69
69
  # @param [Integer] timeout Default timeout to use in requests. Optional.
70
- # @param [Hash] client_config A hash of values to override the default
71
- # behavior of the API client. Optional.
72
70
  # @param [String] endpoint Override of the endpoint host name. Optional.
73
71
  # If the param is nil, uses the default endpoint.
74
72
  # @param [String] project Project identifier for the Stackdriver Debugger
@@ -84,15 +82,20 @@ module Google
84
82
  # debugger = Google::Cloud::Debugger.new
85
83
  # debugger.start
86
84
  #
87
- def self.new project_id: nil, credentials: nil, service_name: nil,
88
- service_version: nil, scope: nil, timeout: nil,
89
- client_config: nil, endpoint: nil, project: nil, keyfile: nil
85
+ def self.new project_id: nil,
86
+ credentials: nil,
87
+ service_name: nil,
88
+ service_version: nil,
89
+ scope: nil,
90
+ timeout: nil,
91
+ endpoint: nil,
92
+ project: nil,
93
+ keyfile: nil
90
94
  project_id ||= (project || default_project_id)
91
95
  service_name ||= default_service_name
92
96
  service_version ||= default_service_version
93
97
  scope ||= configure.scope
94
98
  timeout ||= configure.timeout
95
- client_config ||= configure.client_config
96
99
  endpoint ||= configure.endpoint
97
100
 
98
101
  service_name = service_name.to_s
@@ -114,14 +117,8 @@ module Google
114
117
  project_id = project_id.to_s # Always cast to a string
115
118
  raise ArgumentError, "project_id is missing" if project_id.empty?
116
119
 
117
- Debugger::Project.new(
118
- Debugger::Service.new(
119
- project_id, credentials,
120
- host: endpoint, timeout: timeout, client_config: client_config
121
- ),
122
- service_name: service_name,
123
- service_version: service_version
124
- )
120
+ service = Debugger::Service.new project_id, credentials, host: endpoint, timeout: timeout
121
+ Debugger::Project.new service, service_name: service_name, service_version: service_version
125
122
  end
126
123
 
127
124
  # rubocop:enable all
@@ -147,8 +144,6 @@ module Google
147
144
  # * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
148
145
  # the set of resources and operations that the connection can access.
149
146
  # * `timeout` - (Integer) Default timeout to use in requests.
150
- # * `client_config` - (Hash) A hash of values to override the default
151
- # behavior of the API client.
152
147
  # * `endpoint` - (String) Override of the endpoint host name, or `nil`
153
148
  # to use the default endpoint.
154
149
  # * `allow_mutating_methods` - (boolean) Whether expressions and
@@ -254,4 +249,11 @@ module Google
254
249
  end
255
250
  end
256
251
  end
252
+
253
+ # Aliases for compatibility with older spellings.
254
+ # @private
255
+ module Devtools
256
+ # @private
257
+ Clouddebugger = ::Google::Cloud::Debugger unless const_defined? :Clouddebugger
258
+ end
257
259
  end
@@ -30,7 +30,7 @@ module Google
30
30
  #
31
31
  # Abstract class that represents a breakpoint, which can be set and
32
32
  # triggered in a debuggee application. Maps to gRPC struct
33
- # {Google::Devtools::Clouddebugger::V2::Breakpoint}.
33
+ # {Google::Cloud::Debugger::V2::Breakpoint}.
34
34
  #
35
35
  class Breakpoint
36
36
  include MonitorMixin
@@ -174,7 +174,7 @@ module Google
174
174
 
175
175
  ##
176
176
  # @private New Google::Cloud::Debugger::Breakpoint
177
- # from a Google::Devtools::Clouddebugger::V2::Breakpoint object.
177
+ # from a Google::Cloud::Debugger::V2::Breakpoint object.
178
178
  def self.from_grpc grpc
179
179
  return new if grpc.nil?
180
180
 
@@ -337,9 +337,9 @@ module Google
337
337
 
338
338
  ##
339
339
  # @private Exports the Breakpoint to a
340
- # Google::Devtools::Clouddebugger::V2::Breakpoint object.
340
+ # Google::Cloud::Debugger::V2::Breakpoint object.
341
341
  def to_grpc
342
- Google::Devtools::Clouddebugger::V2::Breakpoint.new(
342
+ Google::Cloud::Debugger::V2::Breakpoint.new(
343
343
  id: id.to_s,
344
344
  location: location.to_grpc,
345
345
  condition: condition.to_s,
@@ -398,7 +398,7 @@ module Google
398
398
 
399
399
  ##
400
400
  # @private Formats the labels so they can be saved to a
401
- # Google::Devtools::Clouddebugger::V2::Breakpoint object.
401
+ # Google::Cloud::Debugger::V2::Breakpoint object.
402
402
  def labels_to_grpc
403
403
  # Coerce symbols to strings
404
404
  Hash[labels.map do |k, v|
@@ -408,21 +408,21 @@ module Google
408
408
 
409
409
  ##
410
410
  # @private Exports the Breakpoint stack_frames to an array of
411
- # Google::Devtools::Clouddebugger::V2::StackFrame objects.
411
+ # Google::Cloud::Debugger::V2::StackFrame objects.
412
412
  def stack_frames_to_grpc
413
413
  stack_frames.nil? ? [] : stack_frames.map(&:to_grpc)
414
414
  end
415
415
 
416
416
  ##
417
417
  # @private Exports the Breakpoint stack_frames to an array of
418
- # Google::Devtools::Clouddebugger::V2::Variable objects.
418
+ # Google::Cloud::Debugger::V2::Variable objects.
419
419
  def evaluated_expressions_to_grpc
420
420
  evaluated_expressions.nil? ? [] : evaluated_expressions.map(&:to_grpc)
421
421
  end
422
422
 
423
423
  ##
424
424
  # @private Exports Breakpoint status to
425
- # Google::Devtools::Clouddebugger::V2::StatusMessage object
425
+ # Google::Cloud::Debugger::V2::StatusMessage object
426
426
  def status_to_grpc
427
427
  status.nil? ? nil : status.to_grpc
428
428
  end
@@ -89,7 +89,7 @@ module Google
89
89
  ##
90
90
  # @private Predefined regex. Saves time during runtime.
91
91
  FUNC_CALL_FLAG_BLACKLIST_REGEX =
92
- /<callinfo!.+#{FUNC_CALL_FLAG_BLACKLIST.join '|'}/.freeze
92
+ /<call(info|data)!.+#{FUNC_CALL_FLAG_BLACKLIST.join '|'}/.freeze
93
93
 
94
94
  ##
95
95
  # @private Predefined regex. Saves time during runtime.
@@ -41,7 +41,7 @@ module Google
41
41
 
42
42
  ##
43
43
  # @private New Google::Cloud::Debugger::Breakpoint::SourceLocation
44
- # from a Google::Devtools::Clouddebugger::V2::SourceLocation object.
44
+ # from a Google::Cloud::Debugger::V2::SourceLocation object.
45
45
  def self.from_grpc grpc
46
46
  return new if grpc.nil?
47
47
  new.tap do |o|
@@ -59,10 +59,10 @@ module Google
59
59
 
60
60
  ##
61
61
  # @private Exports the SourceLocation to a
62
- # Google::Devtools::Clouddebugger::V2::SourceLocation object.
62
+ # Google::Cloud::Debugger::V2::SourceLocation object.
63
63
  def to_grpc
64
64
  return nil if empty?
65
- Google::Devtools::Clouddebugger::V2::SourceLocation.new(
65
+ Google::Cloud::Debugger::V2::SourceLocation.new(
66
66
  path: path.to_s,
67
67
  line: line
68
68
  )
@@ -55,7 +55,7 @@ module Google
55
55
 
56
56
  ##
57
57
  # @private New Google::Cloud::Debugger::Breakpoint::SourceLocation
58
- # from a Google::Devtools::Clouddebugger::V2::SourceLocation object.
58
+ # from a Google::Cloud::Debugger::V2::SourceLocation object.
59
59
  def self.from_grpc grpc
60
60
  new.tap do |o|
61
61
  o.function = grpc.function
@@ -76,10 +76,10 @@ module Google
76
76
 
77
77
  ##
78
78
  # @private Exports the StackFrame to a
79
- # Google::Devtools::Clouddebugger::V2::StackFrame object.
79
+ # Google::Cloud::Debugger::V2::StackFrame object.
80
80
  def to_grpc
81
81
  return nil if empty?
82
- Google::Devtools::Clouddebugger::V2::StackFrame.new(
82
+ Google::Cloud::Debugger::V2::StackFrame.new(
83
83
  function: function.to_s,
84
84
  location: location.to_grpc,
85
85
  arguments: arguments_to_grpc,
@@ -91,14 +91,14 @@ module Google
91
91
 
92
92
  ##
93
93
  # @private Exports the StackFrame arguments to an array of
94
- # Google::Devtools::Clouddebugger::V2::Variable objects.
94
+ # Google::Cloud::Debugger::V2::Variable objects.
95
95
  def arguments_to_grpc
96
96
  arguments.nil? ? [] : arguments.map(&:to_grpc)
97
97
  end
98
98
 
99
99
  ##
100
100
  # @private Exports the StackFrame locals to an array of
101
- # Google::Devtools::Clouddebugger::V2::Variable objects.
101
+ # Google::Cloud::Debugger::V2::Variable objects.
102
102
  def locals_to_grpc
103
103
  locals.nil? ? [] : locals.map(&:to_grpc)
104
104
  end
@@ -50,7 +50,7 @@ module Google
50
50
 
51
51
  ##
52
52
  # New Google::Cloud::Debugger::Breakpoint::StatusMessage
53
- # from a Google::Devtools::Clouddebugger::V2::StatusMessage object.
53
+ # from a Google::Cloud::Debugger::V2::StatusMessage object.
54
54
  def self.from_grpc grpc
55
55
  return nil if grpc.nil?
56
56
  new.tap do |s|
@@ -76,14 +76,12 @@ module Google
76
76
 
77
77
  ##
78
78
  # Exports the StatusMessage to a
79
- # Google::Devtools::Clouddebugger::V2::StatusMessage object.
79
+ # Google::Cloud::Debugger::V2::StatusMessage object.
80
80
  def to_grpc
81
81
  return nil if empty?
82
- description_grpc =
83
- Google::Devtools::Clouddebugger::V2::FormatMessage.new \
84
- format: description.to_s
82
+ description_grpc = Google::Cloud::Debugger::V2::FormatMessage.new format: description.to_s
85
83
 
86
- Google::Devtools::Clouddebugger::V2::StatusMessage.new \
84
+ Google::Cloud::Debugger::V2::StatusMessage.new \
87
85
  is_error: true,
88
86
  refers_to: refers_to,
89
87
  description: description_grpc
@@ -408,7 +408,7 @@ module Google
408
408
 
409
409
  ##
410
410
  # @private New Google::Cloud::Debugger::Breakpoint::Variable
411
- # from a Google::Devtools::Clouddebugger::V2::Variable object.
411
+ # from a Google::Cloud::Debugger::V2::Variable object.
412
412
  def self.from_grpc grpc
413
413
  return new if grpc.nil?
414
414
  new.tap do |o|
@@ -423,7 +423,7 @@ module Google
423
423
 
424
424
  ##
425
425
  # @private New array of Google::Cloud::Debugger::Breakpoint::Variable
426
- # from an array of Google::Devtools::Clouddebugger::V2::Variable
426
+ # from an array of Google::Cloud::Debugger::V2::Variable
427
427
  # objects.
428
428
  def self.from_grpc_list grpc_list
429
429
  return [] if grpc_list.nil?
@@ -458,10 +458,10 @@ module Google
458
458
 
459
459
  ##
460
460
  # Exports the Variable to a
461
- # Google::Devtools::Clouddebugger::V2::Variable object.
461
+ # Google::Cloud::Debugger::V2::Variable object.
462
462
  def to_grpc
463
463
  return nil if empty?
464
- Google::Devtools::Clouddebugger::V2::Variable.new(
464
+ Google::Cloud::Debugger::V2::Variable.new(
465
465
  name: name.to_s,
466
466
  value: value.to_s,
467
467
  type: type.to_s,
@@ -584,7 +584,7 @@ module Google
584
584
 
585
585
  ##
586
586
  # @private Exports the Variable members to an array of
587
- # Google::Devtools::Clouddebugger::V2::Variable objects.
587
+ # Google::Cloud::Debugger::V2::Variable objects.
588
588
  def members_to_grpc
589
589
  members.nil? ? nil : members.map(&:to_grpc)
590
590
  end
@@ -12,9 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
-
16
- require "google/cloud/debugger/v2/credentials"
17
- require "google/cloud/logging/credentials"
15
+ require "google/cloud/debugger/v2/debugger/credentials"
18
16
 
19
17
  module Google
20
18
  module Cloud
@@ -38,9 +36,14 @@ module Google
38
36
  #
39
37
  # debugger.project_id #=> "my-project"
40
38
  #
41
- class Credentials < Google::Cloud::Debugger::V2::Credentials
42
- SCOPE = (Google::Cloud::Debugger::V2::Credentials::SCOPE +
43
- Google::Cloud::Logging::Credentials::SCOPE).uniq.freeze
39
+ class Credentials < Google::Cloud::Debugger::V2::Debugger::Credentials
40
+ self.scope = [
41
+ "https://www.googleapis.com/auth/cloud-platform",
42
+ "https://www.googleapis.com/auth/cloud_debugger",
43
+ "https://www.googleapis.com/auth/logging.admin",
44
+ "https://www.googleapis.com/auth/logging.read",
45
+ "https://www.googleapis.com/auth/logging.write"
46
+ ]
44
47
  end
45
48
  end
46
49
  end
@@ -28,7 +28,7 @@ module Google
28
28
  #
29
29
  # Represent a debuggee application. Contains information that identifies
30
30
  # debuggee applications from each other. Maps to gRPC struct
31
- # {Google::Devtools::Clouddebugger::V2::Debuggee}.
31
+ # Google::Cloud::Debugger::V2::Debuggee.
32
32
  #
33
33
  # It also automatically loads source context information generated from
34
34
  # Cloud SDK. See [Stackdriver Debugger
@@ -111,10 +111,10 @@ module Google
111
111
 
112
112
  ##
113
113
  # Convert this debuggee into a gRPC
114
- # Google::Devtools::Clouddebugger::V2::Debuggee struct.
114
+ # Google::Cloud::Debugger::V2::Debuggee struct.
115
115
  def to_grpc
116
116
  source_context = source_context_from_json_file "source-context.json"
117
- Google::Devtools::Clouddebugger::V2::Debuggee.new(
117
+ Google::Cloud::Debugger::V2::Debuggee.new(
118
118
  id: id.to_s,
119
119
  project: project_id_for_request_arg.to_s,
120
120
  description: description.to_s,
@@ -179,7 +179,7 @@ module Google
179
179
  # project ID if available (and if it matches the project set in the
180
180
  # configuration). Otherwise, use the configured project.
181
181
  def project_id_for_request_arg
182
- if project_id == @env.project_id
182
+ if project_id == @env.lookup_metadata("project", "project-id")
183
183
  numeric_id = @env.numeric_project_id
184
184
  return numeric_id.to_s if numeric_id
185
185
  end
@@ -16,7 +16,6 @@
16
16
  require "google/cloud/errors"
17
17
  require "google/cloud/debugger/version"
18
18
  require "google/cloud/debugger/v2"
19
- require "google/gax/errors"
20
19
  require "uri"
21
20
 
22
21
  module Google
@@ -26,103 +25,63 @@ module Google
26
25
  # @private Represents the gRPC Debugger service, including all the API
27
26
  # methods.
28
27
  class Service
29
- attr_accessor :project, :credentials, :timeout, :client_config, :host
28
+ attr_accessor :project, :credentials, :timeout, :host
30
29
 
31
30
  ##
32
31
  # Creates a new Service instance.
33
- def initialize project, credentials, timeout: nil, client_config: nil,
34
- host: nil
32
+ def initialize project, credentials, timeout: nil, host: nil
35
33
  @project = project
36
34
  @credentials = credentials
37
35
  @timeout = timeout
38
- @client_config = client_config || {}
39
- @host = host || V2::Debugger2Client::SERVICE_ADDRESS
36
+ @host = host
40
37
  end
41
38
 
42
39
  def cloud_debugger
43
40
  return mocked_debugger if mocked_debugger
44
41
  @cloud_debugger ||=
45
- V2::Controller2Client.new(
46
- credentials: credentials,
47
- timeout: timeout,
48
- client_config: client_config,
49
- service_address: service_address,
50
- service_port: service_port,
51
- lib_name: "gccl",
52
- lib_version: Google::Cloud::Debugger::VERSION
53
- )
42
+ V2::Controller::Client.new do |config|
43
+ config.credentials = credentials if credentials
44
+ config.timeout = timeout if timeout
45
+ config.endpoint = host if host
46
+ config.lib_name = "gccl"
47
+ config.lib_version = Google::Cloud::Debugger::VERSION
48
+ config.metadata = { "google-cloud-resource-prefix" => "projects/#{@project}" }
49
+ end
54
50
  end
55
51
  attr_accessor :mocked_debugger
56
52
 
57
53
  def transmitter
58
54
  return mocked_transmitter if mocked_transmitter
59
55
  @transmitter ||=
60
- V2::Controller2Client.new(
61
- credentials: credentials,
62
- timeout: timeout,
63
- client_config: client_config,
64
- service_address: service_address,
65
- service_port: service_port,
66
- lib_name: "gccl",
67
- lib_version: Google::Cloud::Debugger::VERSION
68
- )
56
+ V2::Controller::Client.new do |config|
57
+ config.credentials = credentials if credentials
58
+ config.timeout = timeout if timeout
59
+ config.endpoint = host if host
60
+ config.lib_name = "gccl"
61
+ config.lib_version = Google::Cloud::Debugger::VERSION
62
+ config.metadata = { "google-cloud-resource-prefix" => "projects/#{@project}" }
63
+ end
69
64
  end
70
65
  attr_accessor :mocked_transmitter
71
66
 
72
67
  def register_debuggee debuggee_grpc
73
- execute do
74
- cloud_debugger.register_debuggee debuggee_grpc,
75
- options: default_options
76
- end
68
+ cloud_debugger.register_debuggee debuggee: debuggee_grpc
77
69
  end
78
70
 
79
71
  def list_active_breakpoints debuggee_id, wait_token
80
- execute do
81
- cloud_debugger.list_active_breakpoints debuggee_id.to_s,
82
- wait_token: wait_token.to_s,
83
- success_on_timeout: true,
84
- options: default_options
85
- end
72
+ cloud_debugger.list_active_breakpoints debuggee_id: debuggee_id.to_s,
73
+ wait_token: wait_token.to_s,
74
+ success_on_timeout: true
86
75
  end
87
76
 
88
77
  def update_active_breakpoint debuggee_id, breakpoint
89
- execute do
90
- transmitter.update_active_breakpoint debuggee_id.to_s,
91
- breakpoint.to_grpc,
92
- options: default_options
93
- end
78
+ transmitter.update_active_breakpoint debuggee_id: debuggee_id.to_s,
79
+ breakpoint: breakpoint.to_grpc
94
80
  end
95
81
 
96
82
  def inspect
97
83
  "#{self.class}(#{@project})"
98
84
  end
99
-
100
- protected
101
-
102
- def service_address
103
- return nil if host.nil?
104
- URI.parse("//#{host}").host
105
- end
106
-
107
- def service_port
108
- return nil if host.nil?
109
- URI.parse("//#{host}").port
110
- end
111
-
112
- def default_headers
113
- { "google-cloud-resource-prefix" => "projects/#{@project}" }
114
- end
115
-
116
- def default_options
117
- Google::Gax::CallOptions.new kwargs: default_headers
118
- end
119
-
120
- def execute
121
- yield
122
- rescue Google::Gax::GaxError => e
123
- # GaxError wraps BadStatus, but exposes it as #cause
124
- raise Google::Cloud::Error.from_error(e.cause)
125
- end
126
85
  end
127
86
  end
128
87
  end