0

How do I get the AppEngine service name and version in the GAE flexible env from my Java code at runtime in the Java 8/Jetty runtime?

I need the service and version to populate the ServiceContext info in the stackdriver error reporting on GCP. https://cloud.google.com/error-reporting/docs/formatting-error-messages

successhawk
  • 3,071
  • 3
  • 28
  • 44

2 Answers2

0

I am the Stackdriver Error Reporting product manager.

To answer your question: While I cannot find a clear documentation page for it. It seems that the environment variables GAE_MODULE_NAME and GAE_MODULE_VERSION contain the data you are looking for.

However, we recently changed how errors are processed on App Engine flexible environment: service name and version are now extracted automatically are not needed in the log entry payload. The serviceContext field is now optional on GAE Flex.

The formatting error messages page should be updated in the following days to reflect this change.

Steren
  • 7,311
  • 3
  • 31
  • 51
  • I see the page was updated yesterday, but I don't know what the changes were (one of my biggest complaints with google). The first paragraph says "It should be logged as a multi-line textPayload or in the message field of structPayload." but it doesn't link to anything that explains this. Logged where? What is textPayload and structPayload? – successhawk Sep 29 '16 at 19:23
  • This setup page should contain the answer you are looking for: https://cloud.google.com/error-reporting/docs/setup/app-engine-flexible-environment – Steren Sep 29 '16 at 20:10
  • That is where I started. If I am already doing cloud logging with appropriate severity mapping via this approach ([See my answer here](http://stackoverflow.com/a/39779646/2789445)). Then do I even need to do this [*err*.json](https://cloud.google.com/error-reporting/docs/formatting-error-messages) approach in order to get StackDriver Error Reporting? I currently implemented both because I thought I had to do the latter in order to get StackDriver Error Reporting, and now I am concerned that StackDriver will pick up both and I will get duplicate errors. – successhawk Sep 30 '16 at 20:20
0

According to the current documentation the environment variables GAE_SERVICE and GAE_VERSION should be used.

It is also possible to get the instance ID with the GAE_INSTANCE environment variable.

https://cloud.google.com/appengine/docs/flexible/java/migrating#modules

Rick Clephas
  • 26
  • 1
  • 5