Skip to content
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 non-uniformly throws exceptions on missing/malformed values #512

Closed
artem-karpenko opened this issue Apr 28, 2021 · 2 comments
Assignees
Labels
api: logging Issues related to the googleapis/java-logging API. type: question Request for information or clarification. Not an issue.

Comments

@artem-karpenko
Copy link

I use MonitoredResourceUtil#getResource to load resource in our log4j2 appender implementation (basically migrated logback implementation). Container in which application is running is missing some of the expected labels for "k8s_container" resource type, namely the zone is missing which leads to getCloudRunLocation to throw NPE.

Shouldn't getResource behave lenient against this kind of problems and try to initialize and work with as much data as possible? Especially considering that missing most of the labels will indeed not cause any issues - it's only some of them that lead to exceptions.

@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/java-logging API. label Apr 28, 2021
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 30, 2021
@simonz130 simonz130 added the type: question Request for information or clarification. Not an issue. label May 18, 2021
@yoshi-automation yoshi-automation removed 🚨 This issue needs some love. triage me I really want to be triaged. labels May 18, 2021
@minherz
Copy link
Contributor

minherz commented Sep 30, 2021

hi Artem, thank you for the question. The resource type that you mention "k8s_container" expects to be identified because the process is running in the managed environment i.e. GKE. It means that all metadata is expected to be present. The lack of the metadata means either the resource type was identified incorrectly or there is incompatibility between the library expectations and the environment. In both cases we would like to know about it. Passing empty values hides the problem.
You are right about code throwing NPE is incorrect behavior and has to be fixed. Having said that, can you elaborate more about the deployment which enforces a container without the HOSTNAME envionrment variable. It sounds an interesting corner case and can be useful for us in future.

@minherz
Copy link
Contributor

minherz commented Oct 19, 2021

Hi Artem, we have recently refactored the implementation that populates MonitoredResource with resource type and metadata (#708). Please, use the latest (i think 3.3.0) version of the library.

@minherz minherz closed this as completed Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/java-logging API. type: question Request for information or clarification. Not an issue.
Projects
None yet
4 participants