AppEngine service name and version in the GAE flexible env from my code at runtime in Java/Jetty?

≡放荡痞女 提交于 2020-01-06 16:01:33

问题


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


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/39728297/appengine-service-name-and-version-in-the-gae-flexible-env-from-my-code-at-runti

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!