Skip to content

use ddtrace.auto since patch_all is being deprecated #551

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

Conversation

ZStriker19
Copy link
Collaborator

@ZStriker19 ZStriker19 commented Jan 17, 2025

What does this PR do?

Replaces the instrumentation mechanism of patch_all() with import ddtrace.auto, since patch_all is being deprecated

Motivation

DataDog/dd-trace-py#11918

Testing Guidelines

We'd just hope everything still works as expected

Additional Notes

Types of Changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog
  • This PR passes the integration tests (ask a Datadog member to run the tests)

@ZStriker19 ZStriker19 requested a review from a team as a code owner January 17, 2025 19:37
@ZStriker19 ZStriker19 force-pushed the zachg/update_python_lambda_to_use_ddtraceauto branch from f08fd55 to 0cbdd58 Compare January 17, 2025 19:39
@ZStriker19 ZStriker19 force-pushed the zachg/update_python_lambda_to_use_ddtraceauto branch from 0cbdd58 to 27b8d12 Compare January 17, 2025 19:44
Copy link
Contributor

@purple4reina purple4reina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this change also require us to update the support ddtrace version? We're currently pinning to >=2.17.0

@purple4reina purple4reina self-requested a review January 17, 2025 20:18
@nhulston
Copy link
Contributor

Integration tests are failing with

failed to import ddtrace module 'ddtrace.contrib.requests' when patching on import
Traceback (most recent call last):
File "./python/lib/python3.9/site-packages/ddtrace/_monkey.py", line 175, in on_import
File "/var/lang/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "./python/lib/python3.9/site-packages/ddtrace/internal/module.py", line 295, in _exec_module
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/opt/python/lib/python3.9/site-packages/ddtrace/contrib/requests/__init__.py", line 87, in <module>
from . import patch as _  # noqa: F401, I001
File "./python/lib/python3.9/site-packages/ddtrace/internal/module.py", line 295, in _exec_module
File "./python/lib/python3.9/site-packages/ddtrace/contrib/requests/patch.py", line 1, in <module>
File "./python/lib/python3.9/site-packages/ddtrace/internal/module.py", line 295, in _exec_module
File "./python/lib/python3.9/site-packages/ddtrace/contrib/internal/requests/patch.py", line 7, in <module>
File "./python/lib/python3.9/site-packages/ddtrace/internal/module.py", line 295, in _exec_module
File "./python/lib/python3.9/site-packages/ddtrace/appsec/_common_module_patches.py", line 15, in <module>
File "./python/lib/python3.9/site-packages/ddtrace/internal/module.py", line 295, in _exec_module
File "./python/lib/python3.9/site-packages/ddtrace/appsec/_asm_request_context.py", line 19, in <module>
File "./python/lib/python3.9/site-packages/ddtrace/internal/module.py", line 295, in _exec_module
File "./python/lib/python3.9/site-packages/ddtrace/appsec/_iast/_iast_request_context.py", line 14, in <module>
File "./python/lib/python3.9/site-packages/ddtrace/internal/module.py", line 295, in _exec_module
File "./python/lib/python3.9/site-packages/ddtrace/appsec/_iast/_taint_tracking/__init__.py", line 1, in <module>
ModuleNotFoundError: No module named 'ddtrace.appsec._iast._taint_tracking._native'

@ZStriker19
Copy link
Collaborator Author

Also seeing
< Failed to load product plugin 'code-origin-for-spans'
< Failed to start product 'remote-configuration'

@ZStriker19
Copy link
Collaborator Author

Since ddtrace.auto starts all the products I'm just going to wait till we actually deprecate patch_all, then we can switch to using the internal patch_all method here. Alternatively ddtrace.auto could be used and we'd have to set the proper envars to disable certain products and probably change some logic in tracing.py.

@ZStriker19 ZStriker19 closed this Jan 30, 2025
@anthonyangel
Copy link

Also seeing < Failed to load product plugin 'code-origin-for-spans' < Failed to start product 'remote-configuration'

@ZStriker19 I'm seeing this in a Python lambda using version 69 of the datadog extension and 105 of the Python layer (3.12)

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

Successfully merging this pull request may close these issues.

4 participants