@@ -25,7 +25,7 @@ def construct_ctx():
25
25
so that later subsegment can be attached. After each test run
26
26
it cleans up context storage again.
27
27
"""
28
- from aws_xray_sdk .ext .httplib import unpatch
28
+ from aws_xray_sdk .ext .httplib import unpatch , reset_ignored
29
29
30
30
patch (('httplib' ,))
31
31
xray_recorder .configure (service = 'test' , sampling = False , context = Context ())
@@ -35,6 +35,7 @@ def construct_ctx():
35
35
yield
36
36
xray_recorder .clear_trace_entities ()
37
37
unpatch ()
38
+ reset_ignored ()
38
39
39
40
40
41
def _do_req (url , method = 'GET' , use_https = True ):
@@ -144,62 +145,61 @@ def test_correct_identify_https():
144
145
145
146
146
147
def test_ignore_url ():
147
- from aws_xray_sdk .ext .httplib import add_ignored , reset_ignored
148
+ from aws_xray_sdk .ext .httplib import add_ignored
148
149
path = '/status/200'
149
150
url = 'https://{}{}' .format (BASE_URL , path )
150
151
add_ignored (urls = [path ])
151
152
_do_req (url , use_https = True )
152
153
assert len (xray_recorder .current_segment ().subsegments ) == 0
153
- reset_ignored ()
154
154
155
155
156
156
def test_ignore_hostname ():
157
- from aws_xray_sdk .ext .httplib import add_ignored , reset_ignored
157
+ from aws_xray_sdk .ext .httplib import add_ignored
158
158
path = '/status/200'
159
159
url = 'https://{}{}' .format (BASE_URL , path )
160
160
add_ignored (hostname = BASE_URL )
161
161
_do_req (url , use_https = True )
162
162
assert len (xray_recorder .current_segment ().subsegments ) == 0
163
- reset_ignored ()
164
163
165
164
166
165
def test_ignore_hostname_glob ():
167
- from aws_xray_sdk .ext .httplib import add_ignored , reset_ignored
166
+ from aws_xray_sdk .ext .httplib import add_ignored
168
167
path = '/status/200'
169
168
url = 'https://{}{}' .format (BASE_URL , path )
170
169
add_ignored (hostname = 'http*.org' )
171
170
_do_req (url , use_https = True )
172
171
assert len (xray_recorder .current_segment ().subsegments ) == 0
173
- reset_ignored ()
172
+
173
+
174
+ class TestClass (httplib .HTTPSConnection ):
175
+ pass
174
176
175
177
176
178
def test_ignore_subclass ():
177
- class TestClass (httplib .HTTPSConnection ):
178
- pass
179
- from aws_xray_sdk .ext .httplib import add_ignored , reset_ignored
179
+ from aws_xray_sdk .ext .httplib import add_ignored
180
180
path = '/status/200'
181
181
add_ignored (subclass = 'TestClass' )
182
182
conn = TestClass (BASE_URL )
183
183
conn .request ('GET' , path )
184
184
conn .getresponse ()
185
185
assert len (xray_recorder .current_segment ().subsegments ) == 0
186
- reset_ignored ()
187
186
188
187
189
- def test_ignore_multiple ():
190
- class TestClass (httplib .HTTPSConnection ):
191
- pass
192
- from aws_xray_sdk .ext .httplib import add_ignored , reset_ignored
188
+ def test_ignore_multiple_match ():
189
+ from aws_xray_sdk .ext .httplib import add_ignored
193
190
path = '/status/200'
194
191
add_ignored (subclass = 'TestClass' , hostname = BASE_URL )
195
192
conn = TestClass (BASE_URL )
196
193
conn .request ('GET' , path )
197
194
conn .getresponse ()
198
195
assert len (xray_recorder .current_segment ().subsegments ) == 0
199
- reset_ignored ()
196
+
197
+
198
+ def test_ignore_multiple_no_match ():
199
+ from aws_xray_sdk .ext .httplib import add_ignored
200
+ path = '/status/200'
200
201
add_ignored (subclass = 'TestClass' , hostname = 'fake.host' )
201
202
conn = TestClass (BASE_URL )
202
203
conn .request ('GET' , path )
203
204
conn .getresponse ()
204
205
assert len (xray_recorder .current_segment ().subsegments ) > 0
205
- reset_ignored ()
0 commit comments