You can inspect the runtime state of a Cloud Function using the Stackdriver Debugger. Simply add the debug-agent node module to your function source code (in global scope).
# Install with `npm` or add to your `package.json`. npm install --save @google-cloud/debug-agent
# Require the agent at the top of your main script require('@google-cloud/debug-agent').start();
Deploy your application, and navigate to the Stackdriver Debug view within the Cloud Platform Console to set snapshots and start debugging. To learn more, review the README for the Stackdriver Debugger.
If you want to debug your Cloud Functions locally before you deploy, you can also use a local emulator.