Stackdriver Debugger and New Relic

You can have nice things!

One of my customers discovered a conflict when attempting to configure a Custom Runtime using App Engine Flex with New Relic’s APM agent. The issue arose because the New Relic configuration was replacing the Stackdriver Debugger configuration. The solution was to find a way to configure the JVM for both.

Here’s the working Dockerfile:

I used the New Relic documentation (link) as a starting point but this does not account for Stackdriver Debugger. In truth, a process of trial-and-error resolved the issue which is presented above in the mashed-up version of “JAVA_OPTS”. I then confirmed the solution with Engineering.

You will need a New Relic account in order to make this work. I assume you’re already configured and happily using Google Cloud Platform (GCP). For the Dockerfile defined above, and for simplicity, I located everything in a single directory. If you relocate items, for example, the “newrelic” directory, ensure you reflect this in the ADD statement.

Ensure that the New Relic (newrelic.yml) configuration file is correct. You will need to reflect the “license_key”, and “app_name” values. For debugging (temporarily), I followed the New Relic documentation guidance and set “log_file_name: STDOUT”.

For app.yaml, the New Relic documentation recommends disabling App Engine healthchecks but this is not currently possible with Flex. You should add the environment variable recommendation though and will have something similar to:

From within the directory containing the app.yaml and the Dockerfile, you may then run:

gcloud app deploy --project=$PROJECT --quiet

Once deployed, curl’ing the endpoint yields:

That’s my dawg!

Your app may be more complex than this ;-)

From Stackdriver Debugger, I put a snapshot on line 35 where the output “Hello Henry” is generated:

Stackdriver Debugger: Waiting

Then I issue a curl against the endpoint to trigger it:

Stackdriver Debugger: Captured!

And, at the same time, metrics are being fed into New Relic:

New Relic APM reporting on App Engine Flex


This approach should work with other agents that you wish to combine with Stackdriver Debugger. The trick is to ensure that the Stackdriver Debugger configuration of the Java runtime is preserved.