Skip to content

Commit 07ef999

Browse files
authored
fix(django): patch components on import [backport #5455 to 1.11] (#5774)
Backport of #5455 to 1.11 This change ensures that the Django integration patches the relevant methods and functions only when the containing modules are imported, instead of force-loading them and causing potential side effects. Fixes #5453. ## Testing strategy An additional test case targeting celery with gevent worker classes is added to validate that we don't import from `django` when initialising the library ## Risks The change is equivalent to the original coding feature-wise. The only difference is the removal of potential side-effects from the forced imports. It is unlikely that users relied on those. ## Checklist - [x] Change(s) are motivated and described in the PR description. - [x] Testing strategy is described if automated tests are not included in the PR. - [x] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/contributing.html#Release-Note-Guidelines) are followed. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [x] PR description includes explicit acknowledgement/acceptance of the performance implications of this PR as reported in the benchmarks PR comment. ## Reviewer Checklist - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment.
1 parent eb28db6 commit 07ef999

File tree

24 files changed

+620
-66
lines changed

24 files changed

+620
-66
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ jobs:
702702
parallelism: 2
703703
steps:
704704
- run_test:
705-
pattern: 'django$'
705+
pattern: 'django($|_celery)'
706706
snapshot: true
707707
docker_services: "memcached redis postgres"
708708

.riot/requirements/19ba70f.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.10
3+
# by the following command:
4+
#
5+
# pip-compile --no-annotate --resolver=backtracking .riot/requirements/19ba70f.in
6+
#
7+
amqp==5.1.1
8+
attrs==23.1.0
9+
billiard==3.6.4.0
10+
celery==5.0.5
11+
certifi==2022.12.7
12+
charset-normalizer==3.1.0
13+
click==7.1.2
14+
click-didyoumean==0.3.0
15+
click-plugins==1.1.1
16+
click-repl==0.2.0
17+
coverage[toml]==7.2.5
18+
django==2.2.1
19+
exceptiongroup==1.1.1
20+
gevent==22.10.2
21+
greenlet==2.0.2
22+
hypothesis==6.45.0
23+
idna==3.4
24+
iniconfig==2.0.0
25+
kombu==5.2.4
26+
mock==5.0.2
27+
opentracing==2.4.0
28+
packaging==23.1
29+
pluggy==1.0.0
30+
prompt-toolkit==3.0.38
31+
pytest==7.3.1
32+
pytest-cov==4.0.0
33+
pytest-mock==3.10.0
34+
pytz==2023.3
35+
requests==2.29.0
36+
six==1.16.0
37+
sortedcontainers==2.4.0
38+
sqlalchemy==1.2.19
39+
sqlparse==0.4.4
40+
tomli==2.0.1
41+
urllib3==1.26.15
42+
vine==5.0.0
43+
wcwidth==0.2.6
44+
zope-event==4.6
45+
zope-interface==6.0
46+
47+
# The following packages are considered to be unsafe in a requirements file:
48+
# setuptools

.riot/requirements/1a16fc1.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.9
3+
# by the following command:
4+
#
5+
# pip-compile --no-annotate --resolver=backtracking .riot/requirements/1a16fc1.in
6+
#
7+
amqp==5.1.1
8+
attrs==23.1.0
9+
billiard==3.6.4.0
10+
celery==5.0.5
11+
certifi==2022.12.7
12+
charset-normalizer==3.1.0
13+
click==7.1.2
14+
click-didyoumean==0.3.0
15+
click-plugins==1.1.1
16+
click-repl==0.2.0
17+
coverage[toml]==7.2.5
18+
django==2.2.1
19+
exceptiongroup==1.1.1
20+
gevent==22.10.2
21+
greenlet==2.0.2
22+
hypothesis==6.45.0
23+
idna==3.4
24+
iniconfig==2.0.0
25+
kombu==5.2.4
26+
mock==5.0.2
27+
opentracing==2.4.0
28+
packaging==23.1
29+
pluggy==1.0.0
30+
prompt-toolkit==3.0.38
31+
pytest==7.3.1
32+
pytest-cov==4.0.0
33+
pytest-mock==3.10.0
34+
pytz==2023.3
35+
requests==2.29.0
36+
six==1.16.0
37+
sortedcontainers==2.4.0
38+
sqlalchemy==1.2.19
39+
sqlparse==0.4.4
40+
tomli==2.0.1
41+
urllib3==1.26.15
42+
vine==5.0.0
43+
wcwidth==0.2.6
44+
zope-event==4.6
45+
zope-interface==6.0
46+
47+
# The following packages are considered to be unsafe in a requirements file:
48+
# setuptools

.riot/requirements/1c6d4cc.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.8
3+
# by the following command:
4+
#
5+
# pip-compile --no-annotate --resolver=backtracking .riot/requirements/1c6d4cc.in
6+
#
7+
amqp==5.1.1
8+
attrs==23.1.0
9+
billiard==3.6.4.0
10+
celery==5.0.5
11+
certifi==2022.12.7
12+
charset-normalizer==3.1.0
13+
click==7.1.2
14+
click-didyoumean==0.3.0
15+
click-plugins==1.1.1
16+
click-repl==0.2.0
17+
coverage[toml]==7.2.5
18+
django==2.2.1
19+
exceptiongroup==1.1.1
20+
gevent==22.10.2
21+
greenlet==2.0.2
22+
hypothesis==6.45.0
23+
idna==3.4
24+
iniconfig==2.0.0
25+
kombu==5.2.4
26+
mock==5.0.2
27+
opentracing==2.4.0
28+
packaging==23.1
29+
pluggy==1.0.0
30+
prompt-toolkit==3.0.38
31+
pytest==7.3.1
32+
pytest-cov==4.0.0
33+
pytest-mock==3.10.0
34+
pytz==2023.3
35+
requests==2.29.0
36+
six==1.16.0
37+
sortedcontainers==2.4.0
38+
sqlalchemy==1.2.19
39+
sqlparse==0.4.4
40+
tomli==2.0.1
41+
urllib3==1.26.15
42+
vine==5.0.0
43+
wcwidth==0.2.6
44+
zope-event==4.6
45+
zope-interface==6.0
46+
47+
# The following packages are considered to be unsafe in a requirements file:
48+
# setuptools

.riot/requirements/4a79f8d.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.11
3+
# by the following command:
4+
#
5+
# pip-compile --no-annotate --resolver=backtracking .riot/requirements/4a79f8d.in
6+
#
7+
amqp==5.1.1
8+
attrs==23.1.0
9+
billiard==3.6.4.0
10+
celery==5.0.5
11+
certifi==2022.12.7
12+
charset-normalizer==3.1.0
13+
click==7.1.2
14+
click-didyoumean==0.3.0
15+
click-plugins==1.1.1
16+
click-repl==0.2.0
17+
coverage[toml]==7.2.5
18+
django==2.2.1
19+
gevent==22.10.2
20+
greenlet==2.0.2
21+
hypothesis==6.45.0
22+
idna==3.4
23+
iniconfig==2.0.0
24+
kombu==5.2.4
25+
mock==5.0.2
26+
opentracing==2.4.0
27+
packaging==23.1
28+
pluggy==1.0.0
29+
prompt-toolkit==3.0.38
30+
pytest==7.3.1
31+
pytest-cov==4.0.0
32+
pytest-mock==3.10.0
33+
pytz==2023.3
34+
requests==2.29.0
35+
six==1.16.0
36+
sortedcontainers==2.4.0
37+
sqlalchemy==1.2.19
38+
sqlparse==0.4.4
39+
urllib3==1.26.15
40+
vine==5.0.0
41+
wcwidth==0.2.6
42+
zope-event==4.6
43+
zope-interface==6.0
44+
45+
# The following packages are considered to be unsafe in a requirements file:
46+
# setuptools

0 commit comments

Comments
 (0)