22[ // ] : # " To regenerate it, use `python -m synthtool`. "
33<img src =" https://avatars2.githubusercontent.com/u/2810941?v=3&s=96 " alt =" Google Cloud Platform logo " title =" Google Cloud Platform " align =" right " height =" 96 " width =" 96 " />
44
5- # [ Stackdriver Debugger: Node.js Client] ( https://github.com/googleapis/cloud-debug-nodejs )
5+ # [ Cloud Debugger: Node.js Client] ( https://github.com/googleapis/cloud-debug-nodejs )
66
77[ ![ release level] ( https://img.shields.io/badge/release%20level-stable-brightgreen.svg?style=flat )] ( https://cloud.google.com/terms/launch-stages )
88[ ![ npm version] ( https://img.shields.io/npm/v/@google-cloud/debug-agent.svg )] ( https://www.npmjs.org/package/@google-cloud/debug-agent )
99
1010
1111
1212
13- Stackdriver Debug Agent for Node.js
13+ > This module provides Cloud Debugger support for Node.js applications.
14+ Cloud Debugger is a feature of Google Cloud Platform that lets you debug your
15+ applications in production without stopping or pausing your application.
1416
1517
1618A comprehensive list of changes in each version may be found in
1719[ the CHANGELOG] ( https://github.com/googleapis/cloud-debug-nodejs/blob/main/CHANGELOG.md ) .
1820
19- * [ Stackdriver Debugger Node.js Client API Reference] [ client-docs ]
20- * [ Stackdriver Debugger Documentation] [ product-docs ]
21+ * [ Cloud Debugger Node.js Client API Reference] [ client-docs ]
22+ * [ Cloud Debugger Documentation] [ product-docs ]
2123* [ github.com/googleapis/cloud-debug-nodejs] ( https://github.com/googleapis/cloud-debug-nodejs )
2224
2325Read more about the client libraries for Cloud APIs, including the older
@@ -42,7 +44,7 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained].
4244### Before you begin
4345
44461 . [ Select or create a Cloud Platform project] [ projects ] .
45- 1 . [ Enable the Stackdriver Debugger API] [ enable_api ] .
47+ 1 . [ Enable the Cloud Debugger API] [ enable_api ] .
46481 . [ Set up authentication with a service account] [ auth ] so you can access the
4749 API from your local workstation.
4850
@@ -52,7 +54,106 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained].
5254npm install @google-cloud/debug-agent
5355```
5456
57+ ## Debugger Agent Settings
5558
59+ To customize the behaviour of the automatic debugger agent, specify options
60+ when starting the agent. The following code sample shows how to pass in a
61+ subset of the available options.
62+
63+ ``` js
64+ require (' @google-cloud/debug-agent' ).start ({
65+ // .. auth settings ..
66+
67+ // debug agent settings:
68+ allowExpressions: true ,
69+ serviceContext: {
70+ service: ' my-service' ,
71+ version: ' version-1'
72+ },
73+ capture: { maxFrames: 20 , maxProperties: 100 }
74+ });
75+ ```
76+
77+ See [ the agent configuration] [ config-ts ] for a list of possible configuration
78+ options.
79+
80+ ## Using the Debugger
81+
82+ Once your application is running, use the [ Debug UI] [ debug-tab ] in your Cloud
83+ [ developer console] [ dev-console ] to debug your application. The Debug UI can
84+ be found in the 'Operations -> Debug' section in the navigation panel, or by
85+ simply searching for 'Debug' in the cloud console.
86+
87+ To take a snapshot with the debugger:
88+ 1 . Click in the gutter (line number area) or enter a filename and line number
89+ in the snapshot panel
90+ 2 . The debugger inserts a momentary breakpoint at the specified location in
91+ your code in the running instance of your application.
92+ 3 . As soon as that line of code is reached in any of the running instances of
93+ your application, the stack traces, local variables, and watch expressions
94+ are captured, and your application continues.
95+
96+ ** Note:** The directory layout of the code that is being debugged does not
97+ have to exactly match the source code specified in the Debug UI. This is
98+ because the debug agent resolves a snapshot filename by searching for a file
99+ with the longest matching path suffix. If a unique match is found, that file
100+ will be used to set the snapshot.
101+
102+ ## Firebase Realtime Database backend
103+
104+ The Cloud Debugger API is deprecated and will be turned down in May 2023.
105+
106+ You can use Firebase Realtime Database for data persistence as an
107+ alternative.
108+
109+ ### Enabling the agent
110+
111+ To enable the agent, add the following at the top of your app's main script
112+ or entry point:
113+
114+ ``` js
115+ require (' @google-cloud/debug-agent' ).start ({
116+ useFirebase: true ,
117+ firebaseDbUrl: ' https://my-database-url.firebaseio.com' ,
118+ firebaseKeyPath: ' path/to/service_account.json' ,
119+ });
120+ ```
121+
122+ The following params are optional:
123+ * firebaseDbUrl - https://PROJECT_ID-cdbg.firebase.io.com will be used if not
124+ provided. where PROJECT_ID is your project ID.
125+ * firebaseKeyPath - Default google application credentials are used if not
126+ provided.
127+
128+ ### Using the Debugger
129+
130+ Using the Debugger with the Firebase Realtime Database backend requires using
131+ the Snapshot Debugger CLI.
132+
133+ See the [ full Snapshot Debugger CLI documentation] [ snapshot-debugger-readme ] .
134+
135+ ## Limitations and Requirements
136+
137+ > Note: There is a known issue where enabling the agent may trigger memory
138+ leaks. See [ #811 ] ( https://github.com/googleapis/cloud-debug-nodejs/issues/811 )
139+
140+ * Privacy issues can be created by setting snapshot conditions that watch
141+ expressions evaluated in the context of your application. You may be able
142+ to view sensitive user data when viewing the values of variables.
143+ * The debug agent tries to ensure that all conditions and watchpoints you
144+ add are read-only and have no side effects. It catches, and disallows,
145+ all expressions that may have static side effects to prevent accidental
146+ state change. However, it presently does not catch expressions that have
147+ dynamic side-effects. For example, ` o.f ` looks like a property access,
148+ but dynamically, it may end up calling a getter function. We presently do
149+ NOT detect such dynamic-side effects.
150+ * The root directory of your application needs to contain a ` package.json `
151+ file.
152+
153+ [ config-ts ] : https://github.com/googleapis/cloud-debug-nodejs/blob/master/src/agent/config.ts
154+ [ debug-tab ] : https://console.cloud.google.com/debug
155+ [ dev-console ] : https://console.cloud.google.com/
156+ [ snapshot-debugger-readme ] : https://github.com/GoogleCloudPlatform/snapshot-debugger#readme
56157
57158
58159## Samples
@@ -66,7 +167,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/cloud-debug-nodejs
66167
67168
68169
69- The [ Stackdriver Debugger Node.js Client API Reference] [ client-docs ] documentation
170+ The [ Cloud Debugger Node.js Client API Reference] [ client-docs ] documentation
70171also contains samples.
71172
72173## Supported Node.js Versions
0 commit comments