Skip to content
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

chore(auto-inject): add package instrumentation skipping and denylist #9685

Open
wants to merge 29 commits into
base: main
Choose a base branch
from

Conversation

ZStriker19
Copy link
Contributor

@ZStriker19 ZStriker19 commented Jul 1, 2024

Currently the python tracer will abort instrumentation entirely if a package that's outside of the supported range is detected. Instead it should follow the behavior of other tracers and simply skip instrumenting that particular package, and then instrument the rest of the supported packages.

In addition, the Python tracer should skip instrumentation if uwsgi is detected since it's only compatible with uwsgi under specific conditions: https://ddtrace.readthedocs.io/en/stable/advanced_usage.html?highlight=uwsgi#uwsgi

Checklist

  • Change(s) are motivated and described in the PR description
  • Testing strategy is described if automated tests are not included in the PR
  • Risks are described (performance impact, potential for breakage, maintainability)
  • Change is maintainable (easy to change, telemetry, documentation)
  • Library release note guidelines are followed or label changelog/no-changelog is set
  • Documentation is included (in-code, generated user docs, public corp docs)
  • Backport labels are set (if applicable)
  • If this PR changes the public interface, I've notified @DataDog/apm-tees.

Reviewer Checklist

  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Description motivates each change
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Change is maintainable (easy to change, telemetry, documentation)
  • Release note makes sense to a user of the library
  • Author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

@ZStriker19 ZStriker19 added the changelog/no-changelog A changelog entry is not required for this PR. label Jul 1, 2024
@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Jul 1, 2024

Datadog Report

Branch report: zachg/fix_lib_injection_integration_bailing_and_add_default_path
Commit report: f6ecccd
Test service: dd-trace-py

✅ 0 Failed, 8459 Passed, 14412 Skipped, 1h 58m 14.07s Total duration (6.17s time saved)

@pr-commenter
Copy link

pr-commenter bot commented Jul 1, 2024

Benchmarks

Benchmark execution time: 2024-11-08 20:25:29

Comparing candidate commit cf4069d in PR branch zachg/fix_lib_injection_integration_bailing_and_add_default_path with baseline commit 6272798 in branch main.

Found 1 performance improvements and 0 performance regressions! Performance is the same for 387 metrics, 2 unstable metrics.

scenario:iast_aspects-replace_aspect

  • 🟩 execution_time [-638.573ns; -564.497ns] or [-8.840%; -7.815%]

@codecov-commenter
Copy link

codecov-commenter commented Jul 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 10.54%. Comparing base (9cce458) to head (3686896).
Report is 4 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #9685       +/-   ##
===========================================
- Coverage   73.93%   10.54%   -63.39%     
===========================================
  Files        1402     1368       -34     
  Lines      130420   127984     -2436     
===========================================
- Hits        96426    13502    -82924     
- Misses      33994   114482    +80488     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

github-actions bot commented Jul 22, 2024

CODEOWNERS have been resolved as:

lib-injection/sources/sitecustomize.py                                  @DataDog/apm-core-python

@ZStriker19 ZStriker19 force-pushed the zachg/fix_lib_injection_integration_bailing_and_add_default_path branch from d5c32f4 to fa0ec02 Compare July 23, 2024 20:37
@@ -248,6 +261,11 @@ def _inject():
_log("site-packages path is %r" % site_pkgs_path, level="debug")
if not os.path.exists(site_pkgs_path):
_log("ddtrace site-packages not found in %r, aborting" % site_pkgs_path, level="error")
telemetry_data.append(
create_count_metric("library_entrypoint.error", ["error_type:" + "site-packages-not-found"])
Copy link
Contributor

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

use f-string or .format to format strings (...read more)

Concatenation of multiple strings is not efficient and make the code hard to read and understand.

Instead of concatenating multiple strings, use an f-string or a format string.

Learn More

View in Datadog  Leave us feedback  Documentation

@@ -296,6 +311,11 @@ def _inject():
_log("site-packages path is %r" % site_pkgs_path, level="debug")
if not os.path.exists(site_pkgs_path):
_log("ddtrace site-packages not found in %r, aborting" % site_pkgs_path, level="error")
telemetry_data.append(
create_count_metric("library_entrypoint.error", ["error_type:" + "site-packages-not-found"])
Copy link
Contributor

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

use f-string or .format to format strings (...read more)

Concatenation of multiple strings is not efficient and make the code hard to read and understand.

Instead of concatenating multiple strings, use an f-string or a format string.

Learn More

View in Datadog  Leave us feedback  Documentation

@@ -296,6 +311,11 @@ def _inject():
_log("site-packages path is %r" % site_pkgs_path, level="debug")
if not os.path.exists(site_pkgs_path):
_log("ddtrace site-packages not found in %r, aborting" % site_pkgs_path, level="error")
telemetry_data.append(
create_count_metric("library_entrypoint.error", ["error_type:" + "site-packages-not-found"])
Copy link
Contributor

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

use f-string or .format to format strings (...read more)

Concatenation of multiple strings is not efficient and make the code hard to read and understand.

Instead of concatenating multiple strings, use an f-string or a format string.

Learn More

View in Datadog  Leave us feedback  Documentation

@ZStriker19 ZStriker19 marked this pull request as ready for review November 8, 2024 20:00
@ZStriker19 ZStriker19 requested a review from a team as a code owner November 8, 2024 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog A changelog entry is not required for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants