DataDog / datadog-serverless-functions

Repo of AWS Lambda and Azure Functions functions that process streams and send data to Datadog
Apache License 2.0
337 stars 383 forks source link

AWS Datadog forwarder 3.111.0 results in import error #790

Open aryzhykau opened 4 months ago

aryzhykau commented 4 months ago

I have deployed lambda function manually, set api secret, gave all necessary permissions and now I'm seeing in logs that error

2024-05-20T11:45:25.526Z    INIT_START Runtime Version: python:3.10.v33 Runtime Version ARN: arn:aws:lambda:us-east-1::runtime:7d32daa3f3e28fa335490a9cc169cfe94357a206b0c1d83dcd6f4a499140819b
2024-05-20T11:45:26.629Z    Unable to get total memory available, using default value of 1024 KB
2024-05-20T11:45:26.629Z    Traceback (most recent call last):
2024-05-20T11:45:26.629Z    File "/var/task/ddtrace/settings/profiling.py", line 24, in _derive_default_heap_sample_size
2024-05-20T11:45:26.629Z    from ddtrace.vendor import psutil
2024-05-20T11:45:26.629Z    File "/var/task/ddtrace/internal/module.py", line 208, in _exec_module
2024-05-20T11:45:26.629Z    self.loader.exec_module(module)
2024-05-20T11:45:26.629Z    File "/var/task/datadog_lambda/cold_start.py", line 111, in wrapped_method
2024-05-20T11:45:26.629Z    return original_exec_module(module)
2024-05-20T11:45:26.629Z    File "/var/task/ddtrace/vendor/psutil/__init__.py", line 96, in <module>
2024-05-20T11:45:26.629Z    from . import _pslinux as _psplatform
2024-05-20T11:45:26.629Z    File "/var/task/ddtrace/internal/module.py", line 208, in _exec_module
2024-05-20T11:45:26.629Z    self.loader.exec_module(module)
2024-05-20T11:45:26.629Z    File "/var/task/datadog_lambda/cold_start.py", line 111, in wrapped_method
2024-05-20T11:45:26.629Z    return original_exec_module(module)
2024-05-20T11:45:26.629Z    File "/var/task/ddtrace/vendor/psutil/_pslinux.py", line 26, in <module>
2024-05-20T11:45:26.629Z    from . import _psutil_linux as cext
2024-05-20T11:45:26.629Z    ImportError: cannot import name '_psutil_linux' from partially initialized module 'ddtrace.vendor.psutil' (most likely due to a circular import) (/var/task/ddtrace/vendor/psutil/__init__.py)
2024-05-20T11:45:26.629Z    [WARNING] 2024-05-20T11:45:26.628Z Unable to get total memory available, using default value of 1024 KB Traceback (most recent call last): File "/var/task/ddtrace/settings/profiling.py", line 24, in _derive_default_heap_sample_size from ddtrace.vendor import psutil File "/var/task/ddtrace/internal/module.py", line 208, in _exec_module self.loader.exec_module(module) File "/var/task/datadog_lambda/cold_start.py", line 111, in wrapped_method return original_exec_module(module) File "/var/task/ddtrace/vendor/psutil/__init__.py", line 96, in <module> from . import _pslinux as _psplatform File "/var/task/ddtrace/internal/module.py", line 208, in _exec_module self.loader.exec_module(module) File "/var/task/datadog_lambda/cold_start.py", line 111, in wrapped_method return original_exec_module(module) File "/var/task/ddtrace/vendor/psutil/_pslinux.py", line 26, in <module> from . import _psutil_linux as cext ImportError: cannot import name '_psutil_linux' from partially initialized module 'ddtrace.vendor.psutil' (most likely due to a circular import) (/var/task/ddtrace/vendor/psutil/__init__.py)
2024-05-20T11:45:26.634Z    START RequestId: 1101045d-dfab-4933-8414-e51af53ae4b3 Version: $LATEST
2024-05-20T11:45:26.635Z    LAMBDA_WARNING: Unhandled exception. The most likely cause is an issue in the function code. However, in rare cases, a Lambda runtime update can cause unexpected function behavior. For functions using managed runtimes, runtime updates can be triggered by a function change, or can be applied automatically. To determine if the runtime has been updated, check the runtime version in the INIT_START log entry. If this error correlates with a change in the runtime version, you may be able to mitigate this error by temporarily rolling back to the previous runtime version. For more information, see https://docs.aws.amazon.com/lambda/latest/dg/runtimes-update.html
2024-05-20T11:45:26.635Z    [ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'ddtrace.internal._encoding' Traceback (most recent call last):
2024-05-20T11:45:26.641Z    END RequestId: 1101045d-dfab-4933-8414-e51af53ae4b3
2024-05-20T11:45:26.641Z    REPORT RequestId: 1101045d-dfab-4933-8414-e51af53ae4b3 Duration: 4.44 ms Billed Duration: 5 ms Memory Size: 512 MB Max Memory Used: 88 MB Init Duration: 1107.06 ms

Lambda runtime version is python3.10 following the docs

Describe what you expected: Lambda will be executed normally and operate with s3 events

Steps to reproduce the issue: deploy lambda function version 3.111.0 manually and add an s3 trigger

solivera-prex commented 3 months ago

Hello. I have the same problem. There is any update from Datadog??