Search code examples
node.jsgoogle-cloud-platformgoogle-cloud-functionsstackdriver

Use Stackdriver Debug with Google Cloud Functions


There is a similar question regarding Debugging Firebase Cloud Functions using Stackdriver.

The answer there, however, doesn't seem to help at all with getting Stackdriver Debug to work with my normal Cloud Function (not Firebase). I've tried sourcing the code from Github and a Cloud Source Repository - but that doesn't seem to work. Both times I get in the side bar:

This project does not include any running applications.

The documentation about debugging Cloud Functions seems to say nothing about using Stackdriver Debug. Is there any way to use Stackdriver Debug with Cloud Functions?


Solution

  • I ended up finding the solution from this video: https://youtu.be/BybYim0HRmY?t=21m42s

    Quite simply you add require("@google/cloud-debug") to the top of your index.js (or whatever file your function is in). Then add @google/cloud-debug as a dependency in your package.json.

    You can then manually import the code into Stackdriver Debug and you're good to go.