New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MonitoredResourceUtil#getResource throws error when running locally #569
Comments
@averikitsch can you provide the rest of the configuration like what Logger do you use, its configuration together with the handler implementation? Thank you |
See Steps to reproduce or Add a Cloud Logging handler to a logger |
I am sorry, @averikitsch but I cannot reproduce the error. Would it be possible for you to capture all steps starting with |
Hi I've pushed the code here: https://github.com/averikitsch/java-docs-samples/tree/cloud-logging/run/helloworld.
Then go to: http://localhost:9090/ The failure makes sense, since we are running locally and there is no metadata server. However, this shouldn't throw an error, it should gracefully handle the lack of metadata server or try to retrieve more info from the local environment. |
Thank you, @averikitsch . After reviewing it, the core reason for the failure is that the described way to run the application confuses a resource type auto-detecting mechanism. You can mitigate this behavior by explicitly defining the There is a work in progress to improve the auto-detection mechanism which will resolve a situation when emulated CloudRun fails due to lack of connectivity to a metadata server. |
@simonz130 should we keep this bug and to close it after finishing the work on the auto-detection, WDYT? |
We discussed changing the behavior of Resource Auto-detection to be:
If we change the implementation this way, it will eliminate the null ref. |
A question remains to what resource type the log entries should be tagged if the app runs like described: using environment variables to fake Cloud Run environment. Should it be tagged as a cloud run but without resource name, project, location, etc? |
New resource type discovery resolves the described case (#708). Placing validation of the metadata server as part of the detection mechanism will report local environment as "global" resource type unless a user provides a custom resource type explicitly via |
Environment details
General, Core, and Other are also allowed as types
Steps to reproduce
Call MonitoredResourceUtil.getResource() directly or through using LoggingHandler.addHandler(LOGGER, new LoggingHandler()); for example with
java.util.logging.Logger
.When running locally in a docker container, this library throws a NullPointerException due to the "zone" being null:
Code example
Stack trace
The text was updated successfully, but these errors were encountered: