Skip to content

Commit c909353

Browse files
authored
Prune autoinstrumentation sitecustomize module directory from PYTHONPATH immediately (#1066)
1 parent 2f7a666 commit c909353

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.11.0-0.30b0...HEAD)
99

10+
- Prune autoinstrumentation sitecustomize module directory from PYTHONPATH immediately
11+
([#1066](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1066))
12+
1013
## [1.11.0-0.30b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.11.0-0.30b0) - 2022-04-18
1114

1215
### Fixed

opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,20 @@ def _load_configurators():
110110

111111

112112
def initialize():
113+
# prevents auto-instrumentation of subprocesses if code execs another python process
114+
environ["PYTHONPATH"] = sub(
115+
rf"{dirname(abspath(__file__))}{pathsep}?",
116+
"",
117+
environ["PYTHONPATH"],
118+
)
119+
113120
try:
114121
distro = _load_distros()
115122
distro.configure()
116123
_load_configurators()
117124
_load_instrumentors(distro)
118125
except Exception: # pylint: disable=broad-except
119126
logger.exception("Failed to auto initialize opentelemetry")
120-
finally:
121-
environ["PYTHONPATH"] = sub(
122-
rf"{dirname(abspath(__file__))}{pathsep}?",
123-
"",
124-
environ["PYTHONPATH"],
125-
)
126127

127128

128129
initialize()

0 commit comments

Comments
 (0)