@@ -261,8 +261,9 @@ def test_complex_request(self):
261261 self .assertEqual (200 , django_span .data ["http" ]["status" ])
262262 self .assertEqual ('^complex$' , django_span .data ["http" ]["path_tpl" ])
263263
264- def test_custom_header_capture (self ):
264+ def test_request_header_capture (self ):
265265 # Hack together a manual custom headers list
266+ original_extra_http_headers = agent .options .extra_http_headers
266267 agent .options .extra_http_headers = [u'X-Capture-This' , u'X-Capture-That' ]
267268
268269 request_headers = dict ()
@@ -306,6 +307,49 @@ def test_custom_header_capture(self):
306307 assert "X-Capture-That" in django_span .data ["http" ]["header" ]
307308 self .assertEqual ("that" , django_span .data ["http" ]["header" ]["X-Capture-That" ])
308309
310+ agent .options .extra_http_headers = original_extra_http_headers
311+
312+ def test_response_header_capture (self ):
313+ # Hack together a manual custom headers list
314+ original_extra_http_headers = agent .options .extra_http_headers
315+ agent .options .extra_http_headers = [u'X-Capture-This-Too' ]
316+
317+ with tracer .start_active_span ('test' ):
318+ response = self .http .request ('GET' , self .live_server_url + '/response_with_headers' )
319+
320+ assert response
321+ self .assertEqual (200 , response .status )
322+
323+ spans = self .recorder .queued_spans ()
324+ self .assertEqual (3 , len (spans ))
325+
326+ test_span = spans [2 ]
327+ urllib3_span = spans [1 ]
328+ django_span = spans [0 ]
329+
330+ self .assertEqual ("test" , test_span .data ["sdk" ]["name" ])
331+ self .assertEqual ("urllib3" , urllib3_span .n )
332+ self .assertEqual ("django" , django_span .n )
333+
334+ self .assertEqual (test_span .t , urllib3_span .t )
335+ self .assertEqual (urllib3_span .t , django_span .t )
336+
337+ self .assertEqual (urllib3_span .p , test_span .s )
338+ self .assertEqual (django_span .p , urllib3_span .s )
339+
340+ self .assertEqual (None , django_span .ec )
341+ self .assertIsNone (django_span .stack )
342+
343+ self .assertEqual ('/response_with_headers' , django_span .data ["http" ]["url" ])
344+ self .assertEqual ('GET' , django_span .data ["http" ]["method" ])
345+ self .assertEqual (200 , django_span .data ["http" ]["status" ])
346+ self .assertEqual ('^response_with_headers$' , django_span .data ["http" ]["path_tpl" ])
347+
348+ assert "X-Capture-This-Too" in django_span .data ["http" ]["header" ]
349+ self .assertEqual ("this too" , django_span .data ["http" ]["header" ]["X-Capture-This-Too" ])
350+
351+ agent .options .extra_http_headers = original_extra_http_headers
352+
309353 def test_with_incoming_context (self ):
310354 request_headers = dict ()
311355 request_headers ['X-INSTANA-T' ] = '1'
0 commit comments