From ea0cf3f8d4408cf56aa8d3be63d5fea022ad439b Mon Sep 17 00:00:00 2001 From: Jeremy Voss Date: Thu, 19 May 2022 16:03:58 -0700 Subject: [PATCH] Adding escape call to sitecustomize sub call. Fixes auto-instrumentation not producing spans on Windows. See the following issue: https://github.com/open-telemetry/opentelemetry-python/issues/2703 --- CHANGELOG.md | 3 +++ .../instrumentation/auto_instrumentation/sitecustomize.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fa2badae2..0309007417 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.12.0rc1-0.31b0...HEAD) +- Adding escape call to fix [auto-instrumentation not producing spans on Windows](https://github.com/open-telemetry/opentelemetry-python/issues/2703). + ([#](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/)) + ## [1.12.0rc1-0.31b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.12.0rc1-0.31b0) - 2022-05-17 diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py index 25ee3fe048..37c74a2338 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py @@ -15,7 +15,7 @@ from logging import getLogger from os import environ from os.path import abspath, dirname, pathsep -from re import sub +from re import sub, escape from pkg_resources import iter_entry_points @@ -112,7 +112,7 @@ def _load_configurators(): def initialize(): # prevents auto-instrumentation of subprocesses if code execs another python process environ["PYTHONPATH"] = sub( - rf"{dirname(abspath(__file__))}{pathsep}?", + escape(rf"{dirname(abspath(__file__))}{pathsep}?"), "", environ["PYTHONPATH"], )