-
Notifications
You must be signed in to change notification settings - Fork 450
Labels
Description
Expected Behaviour
DD_FLUSH_TO_LOG is a boolean environment variable and as such should be converted based on it's content rather than used as a string.
Current Behaviour
As long as the variable is set by the user, DD_FLUSH_TO_LOG is used as string and therefore evaluates to true (when used in boolean operations further down), irrespective of the value passed to the environment variable.
Code snippet
DD_FLUSH_TO_LOG=False
import os
from aws_lambda_powertools.metrics.provider.datadog import DatadogMetrics
os.environ["DD_FLUSH_TO_LOG"] = "False"
metrics = DatadogMetrics()
print(metrics.provider.flush_to_log)
>'False'
Possible Solution
Use resolve_truthy_env_var_choice
instead of resolve_env_var_choice here
powertools-lambda-python/aws_lambda_powertools/metrics/provider/datadog/datadog.py
Line 68 in 85666bb
self.flush_to_log = resolve_env_var_choice(choice=flush_to_log, env=os.getenv(constants.DATADOG_FLUSH_TO_LOG)) |
Steps to Reproduce
- Set DD_FLUSH_TO_LOG=False
- leave flush_to_log argument empty when instantiating DatadogMetrics
- check the value of the metrics.provider.flush_to_log / ensure we do not enter here
powertools-lambda-python/aws_lambda_powertools/metrics/provider/datadog/datadog.py
Line 195 in 85666bb
if lambda_metric and not self.flush_to_log:
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.9
Packaging format used
PyPi
Debugging logs
ahached
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Shipped