Skip to content

Commit d566972

Browse files
committed
acept none env var
1 parent 9e466c7 commit d566972

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

aws_lambda_powertools/metrics/provider/cloudwatch_emf/cloudwatch.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,15 @@ def __init__(
9090

9191
@staticmethod
9292
def is_metrics_disabled() -> bool:
93-
"""Checks if metrics have been disabled via POWERTOOLS_METRICS_DISABLE"""
94-
is_disabled = resolve_truthy_env_var_choice(env=os.getenv(constants.METRICS_DISABLED_ENV, "false"))
93+
"""Checks if metrics have been disabled via POWERTOOLS_METRICS_DISABLED"""
94+
if constants.METRICS_DISABLED_ENV not in os.environ:
95+
return False
96+
97+
is_disabled = resolve_truthy_env_var_choice(env=os.getenv(constants.METRICS_DISABLED_ENV))
9598
if is_disabled:
9699
logger.debug("Metrics have been disabled via env var POWERTOOLS_METRICS_DISABLED")
97-
return is_disabled
100+
return bool(is_disabled)
101+
98102

99103
def add_metric(
100104
self,

aws_lambda_powertools/metrics/provider/datadog/datadog.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,14 @@ def __init__(
6969

7070
@staticmethod
7171
def is_metrics_disabled() -> bool:
72-
"""Checks if metrics have been disabled via POWERTOOLS_METRICS_DISABLE"""
73-
is_disabled = resolve_truthy_env_var_choice(env=os.getenv(constants.METRICS_DISABLED_ENV, "false"))
72+
"""Checks if metrics have been disabled via POWERTOOLS_METRICS_DISABLED"""
73+
if constants.METRICS_DISABLED_ENV not in os.environ:
74+
return False
75+
76+
is_disabled = resolve_truthy_env_var_choice(env=os.getenv(constants.METRICS_DISABLED_ENV))
7477
if is_disabled:
7578
logger.debug("Metrics have been disabled via env var POWERTOOLS_METRICS_DISABLED")
76-
return is_disabled
79+
return bool(is_disabled)
7780

7881
# adding name,value,timestamp,tags
7982
def add_metric(

0 commit comments

Comments
 (0)