Skip to content

remove logic that uses import importlib_metadata #13809

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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

chojomok
Copy link
Contributor

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, 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

@chojomok chojomok requested review from a team as code owners June 27, 2025 19:24
@chojomok chojomok marked this pull request as draft June 27, 2025 19:24
@chojomok chojomok requested a review from quinna-h June 27, 2025 19:24
Copy link
Contributor

CODEOWNERS have been resolved as:

ddtrace/contrib/internal/elasticsearch/patch.py                         @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/pyramid/patch.py                               @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/pytest_bdd/patch.py                            @DataDog/ci-app-libraries
ddtrace/internal/gitmetadata.py                                         @DataDog/apm-core-python
ddtrace/internal/packages.py                                            @DataDog/apm-core-python
ddtrace/internal/products.py                                            @DataDog/apm-core-python
tests/appsec/integrations/flask_tests/utils.py                          @DataDog/asm-python
tests/contrib/integration_registry/registry_update_helpers/integration_registry_manager.py  @DataDog/apm-core-python @DataDog/apm-idm-python
tests/utils.py                                                          @DataDog/python-guild

@chojomok chojomok force-pushed the mohammad/update_importlib_metadata branch from cfbf3ed to e837e82 Compare June 27, 2025 19:40
Copy link
Contributor

github-actions bot commented Jun 27, 2025

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

The average import time from this PR is: 188 ± 5 ms.

The average import time from base is: 284 ± 8 ms.

The import time difference between this PR and base is: -95.8 ± 0.3 ms.

Import time breakdown

The following import paths have disappeared:

ddtrace.auto 46.135 ms (24.50%)
ddtrace.bootstrap.sitecustomize 46.135 ms (24.50%)
ddtrace.bootstrap.preload 31.092 ms (16.51%)
ddtrace.internal.remoteconfig.client 7.305 ms (3.88%)
ddtrace.internal.remoteconfig.constants 0.249 ms (0.13%)
ddtrace.internal.symbol_db.remoteconfig 4.280 ms (2.27%)
ddtrace.internal.symbol_db.symbols 3.053 ms (1.62%)
ddtrace.settings.symbol_db 0.414 ms (0.22%)
multiprocessing 3.783 ms (2.01%)
multiprocessing.context 3.461 ms (1.84%)
multiprocessing.reduction 2.269 ms (1.20%)
pickle 1.838 ms (0.98%)
_compat_pickle 0.448 ms (0.24%)
_pickle 0.397 ms (0.21%)
multiprocessing.process 0.459 ms (0.24%)
multiprocessing.sharedctypes 2.620 ms (1.39%)
multiprocessing.heap 1.931 ms (1.03%)
mmap 1.135 ms (0.60%)
multiprocessing.util 0.422 ms (0.22%)
ddtrace.internal.remoteconfig._connectors 2.449 ms (1.30%)
ctypes 2.057 ms (1.09%)
_ctypes 0.655 ms (0.35%)
ctypes._endian 0.440 ms (0.23%)
ddtrace.internal.flare.flare 2.253 ms (1.20%)
logging.handlers 0.838 ms (0.44%)
ddtrace.internal.flare 0.278 ms (0.15%)
ddtrace.appsec._remoteconfiguration 2.211 ms (1.17%)
ddtrace.appsec._capabilities 0.952 ms (0.51%)
ddtrace.debugging._import 1.653 ms (0.88%)
ddtrace.debugging._function.discovery 1.307 ms (0.69%)
ddtrace.debugging._function 0.263 ms (0.14%)
ddtrace.settings.dynamic_instrumentation 0.798 ms (0.42%)
ddtrace.internal.utils.config 0.242 ms (0.13%)
ddtrace.internal.remoteconfig._pubsub 0.662 ms (0.35%)
ddtrace.internal.remoteconfig._subscribers 0.348 ms (0.18%)
ddtrace.debugging._config 0.565 ms (0.30%)
ddtrace.settings.exception_replay 0.322 ms (0.17%)
ddtrace.internal.remoteconfig.worker 0.483 ms (0.26%)
ddtrace.settings.code_origin 0.404 ms (0.21%)
ddtrace.settings.errortracking 0.351 ms (0.19%)
ddtrace.internal.remoteconfig._publishers 0.346 ms (0.18%)
ddtrace.internal.flare._subscribers 0.312 ms (0.17%)
ddtrace.internal.flare.handler 0.311 ms (0.17%)
ddtrace.settings.live_debugging 0.308 ms (0.16%)
ddtrace._trace.trace_handlers 9.913 ms (5.26%)
ddtrace.contrib.trace_utils 3.933 ms (2.09%)
ddtrace.contrib.internal.trace_utils 1.799 ms (0.96%)
ddtrace.contrib.internal.trace_utils_base 0.866 ms (0.46%)
ddtrace.ext.user 0.332 ms (0.18%)
ddtrace.internal.utils.wrappers 0.380 ms (0.20%)
ddtrace.contrib.internal.redis_utils 1.273 ms (0.68%)
ddtrace.contrib.internal 0.366 ms (0.19%)
ddtrace.ext.redis 0.339 ms (0.18%)
ddtrace.contrib.internal.trace_utils_async 0.369 ms (0.20%)
ddtrace._trace._inferred_proxy 3.226 ms (1.71%)
ddtrace.propagation.http 2.709 ms (1.44%)
ddtrace.internal._tagset 0.556 ms (0.30%)
ddtrace.propagation._utils 0.370 ms (0.20%)
ddtrace.propagation 0.346 ms (0.18%)
ddtrace.contrib.internal.botocore.constants 0.755 ms (0.40%)
ddtrace.contrib.internal.botocore 0.354 ms (0.19%)
ddtrace.ext.db 0.404 ms (0.21%)
ddtrace._trace.utils 0.347 ms (0.18%)
ddtrace.ext.azure_servicebus 0.316 ms (0.17%)
ddtrace.appsec._common_module_patches 4.162 ms (2.21%)
ddtrace.appsec._asm_request_context 2.768 ms (1.47%)
ddtrace.appsec._utils 1.518 ms (0.81%)
ddtrace.internal._exceptions 0.371 ms (0.20%)
ddtrace.appsec._metrics 0.876 ms (0.47%)
ddtrace.appsec._deduplications 0.394 ms (0.21%)
shlex 0.502 ms (0.27%)
ddtrace.contrib.internal.subprocess.constants 0.467 ms (0.25%)

The following import paths have grown:

ddtrace.auto 0.209 ms (0.11%)
ddtrace.bootstrap.sitecustomize 0.209 ms (0.11%)
ddtrace.bootstrap.preload 0.209 ms (0.11%)
ddtrace.internal.products 0.134 ms (0.07%)
importlib.metadata 0.134 ms (0.07%)
importlib.abc 0.134 ms (0.07%)
importlib.resources 0.072 ms (0.04%)
ddtrace.internal.runtime.runtime_metrics 0.075 ms (0.04%)

The following import paths have shrunk:

ddtrace.auto 48.137 ms (25.56%)
ddtrace.bootstrap.sitecustomize 47.487 ms (25.21%)
ddtrace.bootstrap.preload 43.337 ms (23.01%)
ddtrace.internal.core.crashtracking 29.654 ms (15.75%)
ddtrace.internal.products 0.145 ms (0.08%)
importlib.metadata 0.145 ms (0.08%)
importlib.abc 0.081 ms (0.04%)
importlib.resources 0.081 ms (0.04%)
importlib.resources._legacy 0.081 ms (0.04%)
importlib.metadata._itertools 0.064 ms (0.03%)
ddtrace.internal.runtime.runtime_metrics 0.092 ms (0.05%)
ddtrace.internal.runtime.tag_collectors 0.092 ms (0.05%)
sitecustomize 0.121 ms (0.06%)
ddtrace 0.650 ms (0.35%)

@pr-commenter
Copy link

pr-commenter bot commented Jul 1, 2025

Benchmarks

Benchmark execution time: 2025-07-01 21:57:09

Comparing candidate commit 7b64179 in PR branch mohammad/update_importlib_metadata with baseline commit 5175caa in branch main.

Found 46 performance improvements and 0 performance regressions! Performance is the same for 441 metrics, 3 unstable metrics.

scenario:djangosimple-appsec

  • 🟩 execution_time [-7.181ms; -7.047ms] or [-33.335%; -32.712%]
  • 🟩 max_rss_usage [-13.192MB; -12.995MB] or [-20.671%; -20.362%]

scenario:djangosimple-exception-replay-enabled

  • 🟩 execution_time [-818.718µs; -803.418µs] or [-60.206%; -59.081%]
  • 🟩 max_rss_usage [-14.106MB; -13.852MB] or [-22.296%; -21.893%]

scenario:djangosimple-iast

  • 🟩 execution_time [-7.326ms; -7.188ms] or [-33.935%; -33.300%]
  • 🟩 max_rss_usage [-13.124MB; -12.907MB] or [-20.583%; -20.243%]

scenario:djangosimple-span-code-origin

  • 🟩 execution_time [-13.082ms; -12.964ms] or [-47.926%; -47.493%]
  • 🟩 max_rss_usage [-15.331MB; -15.111MB] or [-23.234%; -22.900%]

scenario:djangosimple-tracer

  • 🟩 execution_time [-7.128ms; -7.000ms] or [-33.185%; -32.588%]
  • 🟩 max_rss_usage [-13.163MB; -12.945MB] or [-20.651%; -20.309%]

scenario:djangosimple-tracer-and-profiler

  • 🟩 execution_time [-8.299ms; -8.131ms] or [-34.573%; -33.875%]
  • 🟩 max_rss_usage [-13.102MB; -12.772MB] or [-20.108%; -19.602%]

scenario:djangosimple-tracer-no-caches

  • 🟩 execution_time [-4.703ms; -4.605ms] or [-24.824%; -24.306%]
  • 🟩 max_rss_usage [-13.129MB; -12.979MB] or [-20.598%; -20.362%]

scenario:djangosimple-tracer-no-databases

  • 🟩 execution_time [-5.209ms; -5.096ms] or [-26.887%; -26.304%]
  • 🟩 max_rss_usage [-13.129MB; -12.901MB] or [-20.578%; -20.221%]

scenario:djangosimple-tracer-no-middleware

  • 🟩 execution_time [-7.061ms; -6.944ms] or [-33.159%; -32.609%]
  • 🟩 max_rss_usage [-13.050MB; -12.861MB] or [-20.468%; -20.172%]

scenario:djangosimple-tracer-no-templates

  • 🟩 execution_time [-7.124ms; -7.002ms] or [-33.335%; -32.766%]
  • 🟩 max_rss_usage [-13.223MB; -12.995MB] or [-20.734%; -20.377%]

scenario:errortrackingdjangosimple-errortracking-enabled-all

  • 🟩 execution_time [-4.650ms; -4.533ms] or [-25.066%; -24.433%]
  • 🟩 max_rss_usage [-13.070MB; -12.872MB] or [-20.501%; -20.189%]

scenario:errortrackingdjangosimple-errortracking-enabled-user

  • 🟩 execution_time [-4.661ms; -4.561ms] or [-25.080%; -24.542%]
  • 🟩 max_rss_usage [-13.205MB; -12.974MB] or [-20.724%; -20.363%]

scenario:errortrackingdjangosimple-tracer-enabled

  • 🟩 execution_time [-4.557ms; -4.440ms] or [-24.443%; -23.818%]
  • 🟩 max_rss_usage [-13.279MB; -13.048MB] or [-20.798%; -20.436%]

scenario:errortrackingflasksqli-errortracking-enabled-all

  • 🟩 execution_time [-1.480ms; -1.472ms] or [-68.818%; -68.442%]
  • 🟩 max_rss_usage [-7.915MB; -7.695MB] or [-15.408%; -14.979%]

scenario:errortrackingflasksqli-errortracking-enabled-user

  • 🟩 execution_time [-1.476ms; -1.468ms] or [-68.636%; -68.256%]
  • 🟩 max_rss_usage [-7.866MB; -7.666MB] or [-15.311%; -14.923%]

scenario:errortrackingflasksqli-tracer-enabled

  • 🟩 execution_time [-1.477ms; -1.470ms] or [-68.804%; -68.487%]
  • 🟩 max_rss_usage [-7.891MB; -7.680MB] or [-15.360%; -14.950%]

scenario:flasksimple-appsec-get

  • 🟩 execution_time [-2.779ms; -2.768ms] or [-59.954%; -59.716%]
  • 🟩 max_rss_usage [-16.111MB; -15.884MB] or [-26.026%; -25.659%]

scenario:flasksimple-appsec-post

  • 🟩 execution_time [-4.711ms; -4.697ms] or [-75.277%; -75.065%]
  • 🟩 max_rss_usage [-16.109MB; -15.883MB] or [-26.023%; -25.658%]

scenario:flasksimple-appsec-telemetry

  • 🟩 execution_time [-2.788ms; -2.774ms] or [-60.036%; -59.737%]
  • 🟩 max_rss_usage [-16.119MB; -15.875MB] or [-26.090%; -25.695%]

scenario:flasksimple-tracer

  • 🟩 execution_time [-1.567ms; -1.555ms] or [-45.769%; -45.430%]
  • 🟩 max_rss_usage [-7.879MB; -7.771MB] or [-15.302%; -15.091%]

scenario:flasksqli-appsec-enabled

  • 🟩 execution_time [-3.325ms; -3.312ms] or [-83.426%; -83.114%]
  • 🟩 max_rss_usage [-16.466MB; -16.250MB] or [-26.478%; -26.130%]

scenario:flasksqli-iast-enabled

  • 🟩 execution_time [-1.951ms; -1.925ms] or [-74.898%; -73.892%]
  • 🟩 max_rss_usage [-8.426MB; -8.246MB] or [-14.881%; -14.563%]

scenario:flasksqli-tracer-enabled

  • 🟩 execution_time [-1.474ms; -1.467ms] or [-68.910%; -68.565%]
  • 🟩 max_rss_usage [-7.902MB; -7.669MB] or [-15.394%; -14.939%]

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.

1 participant