Skip to content

fix(metrics): ensure proper type conversion for DD_FLUSH_TO_LOG env var #6280

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

Merged
merged 9 commits into from
Mar 18, 2025
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dev-gitpod:

# Running licensecheck with zero to break the pipeline if there is an invalid license
check-licenses:
poetry run licensecheck -u poetry:dev --zero
poetry run licensecheck -u poetry:dev

format:
poetry run black aws_lambda_powertools tests examples
Expand Down
5 changes: 4 additions & 1 deletion aws_lambda_powertools/metrics/provider/datadog/datadog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from aws_lambda_powertools.metrics.provider import BaseProvider
from aws_lambda_powertools.metrics.provider.datadog.warnings import DatadogDataValidationWarning
from aws_lambda_powertools.shared import constants
from aws_lambda_powertools.shared.functions import resolve_env_var_choice
from aws_lambda_powertools.shared.functions import resolve_env_var_choice, strtobool

if TYPE_CHECKING:
from aws_lambda_powertools.shared.types import AnyCallableT
Expand Down Expand Up @@ -66,6 +66,9 @@ def __init__(
)
self.default_tags = default_tags or {}
self.flush_to_log = resolve_env_var_choice(choice=flush_to_log, env=os.getenv(constants.DATADOG_FLUSH_TO_LOG))
# When set as env var, the value is a string
if isinstance(self.flush_to_log, str):
self.flush_to_log = strtobool(self.flush_to_log)

# adding name,value,timestamp,tags
def add_metric(
Expand Down
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def test_with_datadog_as_required_package(session: nox.Session):
folders=[
f"{PREFIX_TESTS_FUNCTIONAL}/metrics/datadog/",
],
extras="datadog,aws-sdk", # Datadog library requires boto3
)


Expand Down
Loading
Loading