@@ -320,6 +320,74 @@ def test_301(self):
320320 # We should NOT have a path template for this route
321321 self .assertIsNone (wsgi_span .data ["http" ]["path_tpl" ])
322322
323+ def test_custom_404 (self ):
324+ with tracer .start_active_span ('test' ):
325+ response = self .http .request ('GET' , testenv ["wsgi_server" ] + '/custom-404' )
326+
327+ spans = self .recorder .queued_spans ()
328+
329+ self .assertEqual (3 , len (spans ))
330+
331+ wsgi_span = spans [0 ]
332+ urllib3_span = spans [1 ]
333+ test_span = spans [2 ]
334+
335+ assert response
336+ self .assertEqual (404 , response .status )
337+
338+ # assert('X-Instana-T' in response.headers)
339+ # assert(int(response.headers['X-Instana-T'], 16))
340+ # self.assertEqual(response.headers['X-Instana-T'], wsgi_span.t)
341+ #
342+ # assert('X-Instana-S' in response.headers)
343+ # assert(int(response.headers['X-Instana-S'], 16))
344+ # self.assertEqual(response.headers['X-Instana-S'], wsgi_span.s)
345+ #
346+ # assert('X-Instana-L' in response.headers)
347+ # self.assertEqual(response.headers['X-Instana-L'], '1')
348+ #
349+ # assert('Server-Timing' in response.headers)
350+ # server_timing_value = "intid;desc=%s" % wsgi_span.t
351+ # self.assertEqual(response.headers['Server-Timing'], server_timing_value)
352+
353+ self .assertIsNone (tracer .active_span )
354+
355+ # Same traceId
356+ self .assertEqual (test_span .t , urllib3_span .t )
357+ self .assertEqual (test_span .t , wsgi_span .t )
358+
359+ # Parent relationships
360+ self .assertEqual (urllib3_span .p , test_span .s )
361+ self .assertEqual (wsgi_span .p , urllib3_span .s )
362+
363+ # Error logging
364+ self .assertIsNone (test_span .ec )
365+ self .assertEqual (None , urllib3_span .ec )
366+ self .assertEqual (None , wsgi_span .ec )
367+
368+ # wsgi
369+ self .assertEqual ("wsgi" , wsgi_span .n )
370+ self .assertEqual ('127.0.0.1:' + str (testenv ['wsgi_port' ]), wsgi_span .data ["http" ]["host" ])
371+ self .assertEqual ('/custom-404' , wsgi_span .data ["http" ]["url" ])
372+ self .assertEqual ('GET' , wsgi_span .data ["http" ]["method" ])
373+ self .assertEqual (404 , wsgi_span .data ["http" ]["status" ])
374+ self .assertIsNone (wsgi_span .data ["http" ]["error" ])
375+ self .assertIsNotNone (wsgi_span .stack )
376+ self .assertEqual (2 , len (wsgi_span .stack ))
377+
378+ # urllib3
379+ self .assertEqual ("test" , test_span .data ["sdk" ]["name" ])
380+ self .assertEqual ("urllib3" , urllib3_span .n )
381+ self .assertEqual (404 , urllib3_span .data ["http" ]["status" ])
382+ self .assertEqual (testenv ["wsgi_server" ] + '/custom-404' , urllib3_span .data ["http" ]["url" ])
383+ self .assertEqual ("GET" , urllib3_span .data ["http" ]["method" ])
384+ self .assertIsNotNone (urllib3_span .stack )
385+ self .assertTrue (type (urllib3_span .stack ) is list )
386+ self .assertTrue (len (urllib3_span .stack ) > 1 )
387+
388+ # We should NOT have a path template for this route
389+ self .assertIsNone (wsgi_span .data ["http" ]["path_tpl" ])
390+
323391 def test_404 (self ):
324392 with tracer .start_active_span ('test' ):
325393 response = self .http .request ('GET' , testenv ["wsgi_server" ] + '/11111111111' )
0 commit comments