How to enable continuous profiling in production

GCP supports continuous CPU and heap profiling. We already have it enabled for some services; you can see some flamegraphs in the GCP profiler dashboard. Turning it for another service requires two small steps:

  1. Initialize the profiler in the service. (example PR)
  2. Set the SOURCEGRAPHDOTCOM_MODE environment variable in the production config to "true". (example PR)

Once the new configuration is deployed to production, you should be able to access profiles for your service in the dashboard.

Other resources: