google-cloud-debugger - Module Google::Cloud::Debugger (v0.42.2)

Reference documentation and code samples for the google-cloud-debugger module Google::Cloud::Debugger.

Stackdriver Debugger

Stackdriver Debugger is a feature of the Google Cloud Platform that lets you inspect the state of an application at any code location without using logging statements and without stopping or slowing down your applications. Your users are not impacted during debugging. Using the production debugger you can capture the local variables and call stack and link it back to a specific line location in your source code. You can use this to analyze the production state of your application and understand the behavior of your code in production.

See Debugger Overview.

Methods

.allow_mutating_methods!

def self.allow_mutating_methods!(&block)

Allow calling of potentially state-changing methods even if mutation detection is configured to be active.

Generally it is unwise to run code that may change the program state (e.g. modifying instance variables or causing other side effects) in a breakpoint expression, because it could change the behavior of your program. However, the checks are currently quite conservative, and may block code that is actually safe to run. If you are certain your expression is safe to evaluate, you may use this method to disable side effect checks.

This method may be called with a block, in which case checks are disabled within the block. It may also be called without a block to disable side effect checks for the rest of the current expression; the default setting will be restored for the next expression.

This method may be called only from a debugger condition or expression evaluation, and will throw an exception if you call it from normal application code. Set the allow_mutating_methods configuration if you want to disable the side effect checker globally for your app.

Examples

Disabling side effect detection in a block

# This is an expression evaluated in a debugger snapshot
Google::Cloud::Debugger.allow_mutating_methods! do
  obj1.method_with_potential_side_effects
end

Disabling side effect detection for the rest of the expression

# This is an expression evaluated in a debugger snapshot
Google::Cloud::Debugger.allow_mutating_methods!
obj1.method_with_potential_side_effects
obj2.another_method_with_potential_side_effects

Globally disabling side effect detection at app initialization

require "google/cloud/debugger"
Google::Cloud::Debugger.configure.allow_mutating_methods = true

.configure

def self.configure() -> Google::Cloud::Config

Configure the Stackdriver Debugger agent.

The following Stackdriver Debugger configuration parameters are supported:

  • project_id - (String) Project identifier for the Stackdriver Debugger service you are connecting to. (The parameter project is considered deprecated, but may also be used.)
  • credentials - (String, Hash, Google::Auth::Credentials) The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See Credentials) (The parameter keyfile is considered deprecated, but may also be used.)
  • service_name - (String) Name for the debuggee application.
  • service_version - (String) Version identifier for the debuggee application.
  • root - (String) The root directory of the debuggee application as an absolute file path.
  • scope - (String, Array
  • quota_project - (String) The project ID for a project that can be used by client libraries for quota and billing purposes.
  • timeout - (Integer) Default timeout to use in requests.
  • endpoint - (String) Override of the endpoint host name, or nil to use the default endpoint.
  • allow_mutating_methods - (boolean) Whether expressions and conditional breakpoints can call methods that could modify program state. Defaults to false.
  • evaluation_time_limit - (Numeric) Time limit in seconds for expression evaluation. Defaults to 0.05.
  • on_error - (Proc) A Proc to be run when an error is encountered on a background thread. The Proc must take the error object as the single argument.

See the Configuration Guide for full configuration parameters.

Yields
  • (Google::Cloud.configure.debugger)
Returns
  • (Google::Cloud::Config) — The configuration object the Google::Cloud::Debugger module uses.

.new

def self.new(project_id: nil, credentials: nil, service_name: nil, service_version: nil, scope: nil, timeout: nil, endpoint: nil, project: nil, keyfile: nil) -> Google::Cloud::Debugger::Project

Creates a new debugger object for instrumenting Stackdriver Debugger for an application. Each call creates a new debugger agent with independent connection service.

For more information on connecting to Google Cloud see the Authentication Guide.

Parameters
  • project_id (String) (defaults to: nil) — Project identifier for the Stackdriver Debugger service you are connecting to. If not present, the default project for the credentials is used.
  • credentials (String, Hash, Google::Auth::Credentials) (defaults to: nil) — The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See Credentials)
  • service_name (String) (defaults to: nil) — Name for the debuggee application. Optional.
  • service_version (String) (defaults to: nil) — Version identifier for the debuggee application. Optional.
  • scope (String, Array<String>) (defaults to: nil)

    The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See Using OAuth 2.0 to Access Google APIs.

    The default scope is:

    • https://www.googleapis.com/auth/cloud_debugger
    • https://www.googleapis.com/auth/logging.admin
  • timeout (Integer) (defaults to: nil) — Default timeout to use in requests. Optional.
  • endpoint (String) (defaults to: nil) — Override of the endpoint host name. Optional. If the param is nil, uses the default endpoint.
  • project (String) (defaults to: nil) — Project identifier for the Stackdriver Debugger service.
  • keyfile (String, Hash) (defaults to: nil) — Keyfile downloaded from Google Cloud: either the JSON data or the path to a readable file.
Raises
  • (ArgumentError)
Example
require "google/cloud/debugger"

debugger = Google::Cloud::Debugger.new
debugger.start

Constants

VERSION

value: "0.42.2".freeze