Skip to content

Setting DD_LOG_LEVEL to TRACE crashes python function #417

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

Closed
MatejBalantic opened this issue Feb 14, 2024 · 4 comments
Closed

Setting DD_LOG_LEVEL to TRACE crashes python function #417

MatejBalantic opened this issue Feb 14, 2024 · 4 comments

Comments

@MatejBalantic
Copy link

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)
@purple4reina
Copy link
Contributor

Hi @MatejBalantic, thanks for reporting this issue. It definitely looks like a bug in our layer. I'll get started on a fix for it.

@purple4reina
Copy link
Contributor

A fix for this has been merged and will go out with our next release. Thanks again for catching this!

@jonlaflamme
Copy link

I'm using the image: public.ecr.aws/datadog/lambda-extension:55 and am encountering the same bug. When do you expect this fix to be released to ECR?

@duncanista
Copy link
Contributor

@jon-laf-nexient-numo these are two different components. You don't need to update the Lambda Extension, you need to update this package to the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants