Skip to content

Commit cbd5f28

Browse files
committed
Add Testing for Instrumentation Patch
1 parent e6ca6ac commit cbd5f28

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_instrumentation_patch.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
3+
import sys
34
from typing import Dict
45
from unittest import TestCase
56
from unittest.mock import MagicMock, patch
@@ -57,12 +58,14 @@ def _run_patch_behaviour_tests(self):
5758

5859
# Validate unpatched upstream behaviour - important to detect upstream changes that may break instrumentation
5960
self._test_unpatched_botocore_instrumentation()
61+
self._test_unpatched_gevent_ssl_instrumentation()
6062

6163
# Apply patches
6264
apply_instrumentation_patches()
6365

6466
# Validate patched upstream behaviour - important to detect downstream changes that may break instrumentation
6567
self._test_patched_botocore_instrumentation()
68+
self._test_patched_gevent_ssl_instrumentation()
6669

6770
# Test teardown
6871
self._reset_mocks()
@@ -93,6 +96,10 @@ def _test_unpatched_botocore_instrumentation(self):
9396
self.assertFalse("aws.sqs.queue_url" in attributes)
9497
self.assertFalse("aws.sqs.queue_name" in attributes)
9598

99+
def _test_unpatched_gevent_ssl_instrumentation(self):
100+
# Ssl
101+
self.assertFalse("gevent.ssl" in sys.modules, "Upstream has added the gevent ssl patch")
102+
96103
def _test_patched_botocore_instrumentation(self):
97104
# Kinesis
98105
self.assertTrue("kinesis" in _KNOWN_EXTENSIONS)
@@ -115,6 +122,10 @@ def _test_patched_botocore_instrumentation(self):
115122
self.assertTrue("aws.sqs.queue_name" in sqs_attributes)
116123
self.assertEqual(sqs_attributes["aws.sqs.queue_name"], _QUEUE_NAME)
117124

125+
def _test_patched_gevent_ssl_instrumentation(self):
126+
# Ssl
127+
self.assertTrue("gevent.ssl" in sys.modules)
128+
118129
def _test_botocore_installed_flag(self):
119130
with patch(
120131
"amazon.opentelemetry.distro.patches._botocore_patches._apply_botocore_instrumentation_patches"

0 commit comments

Comments
 (0)