diff --git a/aws-opentelemetry-distro/src/amazon/opentelemetry/distro/patches/_instrumentation_patch.py b/aws-opentelemetry-distro/src/amazon/opentelemetry/distro/patches/_instrumentation_patch.py index 161850e4c..02d6839ce 100644 --- a/aws-opentelemetry-distro/src/amazon/opentelemetry/distro/patches/_instrumentation_patch.py +++ b/aws-opentelemetry-distro/src/amazon/opentelemetry/distro/patches/_instrumentation_patch.py @@ -34,7 +34,9 @@ def apply_instrumentation_patches() -> None: from gevent import monkey monkey.patch_all() - elif gevent_patch_module != "none": + elif gevent_patch_module == "none": + pass + else: module_list = [module.strip() for module in gevent_patch_module.split(",")] # pylint: disable=import-outside-toplevel diff --git a/aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_instrumentation_patch.py b/aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_instrumentation_patch.py index dbb93d39d..d12040041 100644 --- a/aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_instrumentation_patch.py +++ b/aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_instrumentation_patch.py @@ -59,8 +59,8 @@ def test_instrumentation_patch(self): def _run_patch_behaviour_tests(self): # Test setup self.method_patches[GET_DISTRIBUTION_PATCH].return_value = "CorrectDistributionObject" - # Test setup to check whether only these two modules get patched by gevent monkey - os.environ[AWS_GEVENT_PATCH_MODULES] = "os, ssl" + # Test setup to not patch gevent + os.environ[AWS_GEVENT_PATCH_MODULES] = "none" # Validate unpatched upstream behaviour - important to detect upstream changes that may break instrumentation self._test_unpatched_botocore_instrumentation() @@ -71,6 +71,15 @@ def _run_patch_behaviour_tests(self): # Validate patched upstream behaviour - important to detect downstream changes that may break instrumentation self._test_patched_botocore_instrumentation() + self._test_unpatched_gevent_instrumentation() + + # Test setup to check whether only these two modules get patched by gevent monkey + os.environ[AWS_GEVENT_PATCH_MODULES] = "os, ssl" + + # Apply patches + apply_instrumentation_patches() + + # Validate that os and ssl gevent monkey patch modules were patched self._test_patched_gevent_os_ssl_instrumentation() # Set the value to 'all' so that all the remaining gevent monkey patch modules are patched