You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Putting metrics fails when POWERTOOLS_METRICS_NAMESPACE is not set #1500
Putting metrics will fail with an software.amazon.cloudwatchlogs.emf.exception.InvalidNamespaceException when environment POWERTOOLS_METRICS_NAMESPACE is not set.
What were you trying to accomplish?
After updating cloudwatchlogs-aws-embedded-metrics to 4.1.1 I started to get InvalidNamespaceException when I try to put a metric for example using
Hey @roamingthings , thanks for the report! The requirement for the variable is documented, but it does seem a bit odd to explicitly 1/ check if the default hasn't been overriden, and then 2/ override it with an empty string. Inverting the whole thing as you suggest so we override if we have the env var, or use the default otherwise, seems more sensible, and wouldn't be a breaking change.
Looks to me that we should do the contrary: if the env var is empty, set a default, as you suggest.
But I'm not sure how the context namespace is actually set. I've found this which makes me think that "aws-embedded-metrics" is the default. So if it is the default, we try to replace it with the env var, otherwise, it means the user already changed the default somehow (how?) and we should use that.
What is missing here is the check on SystemWrapper.getenv("POWERTOOLS_METRICS_NAMESPACE". If null or empty, we should come back to the default.
Activity
scottgerring commentedon Nov 7, 2023
Hey @roamingthings , thanks for the report! The requirement for the variable is documented, but it does seem a bit odd to explicitly 1/ check if the default hasn't been overriden, and then 2/ override it with an empty string. Inverting the whole thing as you suggest so we override if we have the env var, or use the default otherwise, seems more sensible, and wouldn't be a breaking change.
What do you think @jeromevdl - ?
jeromevdl commentedon Nov 7, 2023
First, I didn't really understand this code:
Looks to me that we should do the contrary: if the env var is empty, set a default, as you suggest.
But I'm not sure how the context namespace is actually set. I've found this which makes me think that
"aws-embedded-metrics"is the default. So if it is the default, we try to replace it with the env var, otherwise, it means the user already changed the default somehow (how?) and we should use that.What is missing here is the check on
SystemWrapper.getenv("POWERTOOLS_METRICS_NAMESPACE". If null or empty, we should come back to the default.fix #1500
github-actions commentedon Nov 16, 2023
This is now released under 1.18.0 version!
fix #1500 (#1506)
docs: HelloWorldStreamFunction in examples fails with sam (#1532)
chore(v2): Merge down from main (#1574)
fix aws-powertools#1500 (aws-powertools#1506)