AppEngine service name and version in the GAE flex

2019-09-11 05:23发布

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

2条回答
你好瞎i
2楼-- · 2019-09-11 05:46

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.

查看更多
Emotional °昔
3楼-- · 2019-09-11 05:46

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

查看更多
登录 后发表回答