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.
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 snapshotGoogle::Cloud::Debugger.allow_mutating_methods!doobj1.method_with_potential_side_effectsend
Disabling side effect detection for the rest of the expression
# This is an expression evaluated in a debugger snapshotGoogle::Cloud::Debugger.allow_mutating_methods!obj1.method_with_potential_side_effectsobj2.another_method_with_potential_side_effects
Globally disabling side effect detection at app initialization
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.
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) —
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# google-cloud-debugger - Module Google::Cloud::Debugger (v0.42.2)\n\nReference documentation and code samples for the google-cloud-debugger module Google::Cloud::Debugger.\n\nStackdriver Debugger\n--------------------\n\nStackdriver Debugger is a feature of the Google Cloud Platform that lets\nyou inspect the state of an application at any code location without using\nlogging statements and without stopping or slowing down your applications.\nYour users are not impacted during debugging. Using the production\ndebugger you can capture the local variables and call stack and link it\nback to a specific line location in your source code. You can use this to\nanalyze the production state of your application and understand the\nbehavior of your code in production.\n\nSee [Debugger Overview](./index.html \"Debugger Overview\").\n\nMethods\n-------\n\n### .allow_mutating_methods!\n\n def self.allow_mutating_methods!(&block)\n\nAllow calling of potentially state-changing methods even if mutation\ndetection is configured to be active.\n\n\nGenerally it is unwise to run code that may change the program state\n(e.g. modifying instance variables or causing other side effects) in a\nbreakpoint expression, because it could change the behavior of your\nprogram. However, the checks are currently quite conservative, and may\nblock code that is actually safe to run. If you are certain your\nexpression is safe to evaluate, you may use this method to disable\nside effect checks.\n\nThis method may be called with a block, in which case checks are\ndisabled within the block. It may also be called without a block to\ndisable side effect checks for the rest of the current expression; the\ndefault setting will be restored for the next expression.\n\n\u003cbr /\u003e\n\nThis method may be called only from a debugger condition or expression\nevaluation, and will throw an exception if you call it from normal\napplication code. Set the `allow_mutating_methods` configuration if you\nwant to disable the side effect checker globally for your app.\n**Examples**\n\nDisabling side effect detection in a block \n\n```ruby\n# This is an expression evaluated in a debugger snapshot\nGoogle::Cloud::Debugger.allow_mutating_methods! do\n obj1.method_with_potential_side_effects\nend\n```\n\nDisabling side effect detection for the rest of the expression \n\n```ruby\n# This is an expression evaluated in a debugger snapshot\nGoogle::Cloud::Debugger.allow_mutating_methods!\nobj1.method_with_potential_side_effects\nobj2.another_method_with_potential_side_effects\n```\n\nGlobally disabling side effect detection at app initialization \n\n```ruby\nrequire \"google/cloud/debugger\"\nGoogle::Cloud::Debugger.configure.allow_mutating_methods = true\n```\n\n### .configure\n\n def self.configure() -\u003e Google::Cloud::Config\n\nConfigure the Stackdriver Debugger agent.\n\n\nThe following Stackdriver Debugger configuration parameters are\nsupported:\n\n- `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.)\n- `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](/ruby/docs/reference/google-cloud-debugger/latest/Google-Cloud-Debugger-Credentials \"Google::Cloud::Debugger::Credentials (class)\")) (The parameter `keyfile` is considered deprecated, but may also be used.)\n- `service_name` - (String) Name for the debuggee application.\n- `service_version` - (String) Version identifier for the debuggee application.\n- `root` - (String) The root directory of the debuggee application as an absolute file path.\n- `scope` - (String, Array\n- `quota_project` - (String) The project ID for a project that can be used by client libraries for quota and billing purposes.\n- `timeout` - (Integer) Default timeout to use in requests.\n- `endpoint` - (String) Override of the endpoint host name, or `nil` to use the default endpoint.\n- `allow_mutating_methods` - (boolean) Whether expressions and conditional breakpoints can call methods that could modify program state. Defaults to false.\n- `evaluation_time_limit` - (Numeric) Time limit in seconds for expression evaluation. Defaults to 0.05.\n- `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.\n\n\u003cbr /\u003e\n\nSee the [Configuration\nGuide](https://googleapis.dev/ruby/stackdriver/latest/file.INSTRUMENTATION_CONFIGURATION.html)\nfor full configuration parameters. \n**Yields**\n\n- (Google::Cloud.configure.debugger) \n**Returns**\n\n- (Google::Cloud::Config) --- The configuration object the Google::Cloud::Debugger module uses.\n\n### .new\n\n def self.new(project_id: nil, credentials: nil, service_name: nil, service_version: nil, scope: nil, timeout: nil, endpoint: nil, project: nil, keyfile: nil) -\u003e Google::Cloud::Debugger::Project\n\nCreates a new debugger object for instrumenting Stackdriver Debugger for\nan application. Each call creates a new debugger agent with independent\nconnection service.\n\n\n\u003cbr /\u003e\n\nFor more information on connecting to Google Cloud see the\n[Authentication Guide](./AUTHENTICATION \"Authentication Guide\"). \n**Parameters**\n\n- **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.\n- **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](/ruby/docs/reference/google-cloud-debugger/latest/Google-Cloud-Debugger-Credentials \"Google::Cloud::Debugger::Credentials (class)\"))\n- **service_name** (String) *(defaults to: nil)* --- Name for the debuggee application. Optional.\n- **service_version** (String) *(defaults to: nil)* --- Version identifier for the debuggee application. Optional.\n- **scope** (String, Array\\\u003cString\\\u003e) *(defaults to: nil)* ---\n\n The OAuth 2.0 scopes controlling\n the set of resources and operations that the connection can access.\n See [Using OAuth 2.0 to Access Google\n APIs](https://developers.google.com/identity/protocols/OAuth2).\n\n The default scope is:\n - `https://www.googleapis.com/auth/cloud_debugger`\n - `https://www.googleapis.com/auth/logging.admin`\n- **timeout** (Integer) *(defaults to: nil)* --- Default timeout to use in requests. Optional.\n- **endpoint** (String) *(defaults to: nil)* --- Override of the endpoint host name. Optional. If the param is nil, uses the default endpoint.\n- **project** (String) *(defaults to: nil)* --- Project identifier for the Stackdriver Debugger service.\n- **keyfile** (String, Hash) *(defaults to: nil)* --- Keyfile downloaded from Google Cloud: either the JSON data or the path to a readable file. \n**Returns**\n\n- ([Google::Cloud::Debugger::Project](./Google-Cloud-Debugger-Project)) \n**Raises**\n\n- (ArgumentError)\n**Example** \n\n```ruby\nrequire \"google/cloud/debugger\"\n\ndebugger = Google::Cloud::Debugger.new\ndebugger.start\n```\n\nConstants\n---------\n\n### VERSION\n\n**value:**\"0.42.2\".freeze"]]