1
1
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
# SPDX-License-Identifier: Apache-2.0
3
+ import sys
3
4
from typing import Dict
4
5
from unittest import TestCase
5
6
from unittest .mock import MagicMock , patch
@@ -57,12 +58,14 @@ def _run_patch_behaviour_tests(self):
57
58
58
59
# Validate unpatched upstream behaviour - important to detect upstream changes that may break instrumentation
59
60
self ._test_unpatched_botocore_instrumentation ()
61
+ self ._test_unpatched_gevent_ssl_instrumentation ()
60
62
61
63
# Apply patches
62
64
apply_instrumentation_patches ()
63
65
64
66
# Validate patched upstream behaviour - important to detect downstream changes that may break instrumentation
65
67
self ._test_patched_botocore_instrumentation ()
68
+ self ._test_patched_gevent_ssl_instrumentation ()
66
69
67
70
# Test teardown
68
71
self ._reset_mocks ()
@@ -93,6 +96,10 @@ def _test_unpatched_botocore_instrumentation(self):
93
96
self .assertFalse ("aws.sqs.queue_url" in attributes )
94
97
self .assertFalse ("aws.sqs.queue_name" in attributes )
95
98
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
+
96
103
def _test_patched_botocore_instrumentation (self ):
97
104
# Kinesis
98
105
self .assertTrue ("kinesis" in _KNOWN_EXTENSIONS )
@@ -115,6 +122,10 @@ def _test_patched_botocore_instrumentation(self):
115
122
self .assertTrue ("aws.sqs.queue_name" in sqs_attributes )
116
123
self .assertEqual (sqs_attributes ["aws.sqs.queue_name" ], _QUEUE_NAME )
117
124
125
+ def _test_patched_gevent_ssl_instrumentation (self ):
126
+ # Ssl
127
+ self .assertTrue ("gevent.ssl" in sys .modules )
128
+
118
129
def _test_botocore_installed_flag (self ):
119
130
with patch (
120
131
"amazon.opentelemetry.distro.patches._botocore_patches._apply_botocore_instrumentation_patches"
0 commit comments