Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
chore: Update Readme to include isReady interface (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaofanmichael committed Dec 1, 2017
1 parent 248eda1 commit 1d300ac
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,25 @@ process.env['GCLOUD_USE_INSPECTOR'] = true;
require('@google-cloud/debug-agent').start({ ... });
```

## Using Stackdriver Debugger on Google Cloud Functions

The Stackdriver Debugger also introduces a new `isReady` method that returns a `Promise` that is resolved in either of the three scenarios.
1. The debug agent has received snapshot information from the Stackdriver service.
2. The last snapshot received from Stackdriver service is relatively recent.
3. The debug agent has determined that it is not possible to receive snapshot information.

In order for Stackdriver Debugger to work on GCF, users should call the `isReady` function and wait for the returned `Promise` to resolve before exiting the cloud function. The purpose of this is to allow the Debug Agent enough time to sync reasonably up-to-date snapshot information; in most cases this is instantaneous and the worst (rare) case is to delay up to 40 seconds.

```js
const debug = require('@google-cloud/debug-agent').start();
exports.myFunc = (event) => {
const debugReady = debug.isReady();
debugReady.then(() => {
// ...
});
}
```

## Limitations and Requirements
* The root directory of your application needs to contain a `package.json` file.
* You can set snapshot conditions and watch expressions to be evaluated in the context of your application. This leads to some issues you should be aware of
Expand Down

0 comments on commit 1d300ac

Please sign in to comment.