Skip to content

Setting DD_LOG_LEVEL to TRACE crashes python function #417

Closed
@MatejBalantic

Description

@MatejBalantic

Expected Behavior

No crash when setting environment variable DD_LOG_LEVEL to TRACE

Actual Behavior

Crash

Steps to Reproduce the Problem

I am using DataDog lambda extension.
I've set the environment variable DD_LOG_LEVEL to TRACE as one of the allowed values according to the docs.

After deployment, lambda crashed in runtime with the following error:

[ERROR] ValueError: Unknown level: 'Level TRACE'

It seems that the python handler attempts to set python's logger level to mirror DD_LOG_LEVEL, but TRACE isn't one of allowed levels.

Specifications

  • Datadog Lambda Layer version: 52
  • Python version: 3.11

Stacktrace

  File "/var/lang/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1126, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/var/task/datadog_lambda/__init__.py", line 17, in <module>
    logger.setLevel(logging.getLevelName(os.environ.get("DD_LOG_LEVEL", "INFO").upper()))
  File "/var/lang/lib/python3.11/logging/__init__.py", line 1464, in setLevel
    self.level = _checkLevel(level)
  File "/var/lang/lib/python3.11/logging/__init__.py", line 207, in _checkLevel
    raise ValueError("Unknown level: %r" % level)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions