@@ -28,7 +28,7 @@ def tearDown(self):
2828
2929 def test_basic_request (self ):
3030 with tracer .start_active_span ('test' ):
31- response = self .http .request ('GET' , self .live_server_url + '/' )
31+ response = self .http .request ('GET' , self .live_server_url + '/' , fields = { "test" : 1 } )
3232
3333 assert response
3434 self .assertEqual (200 , response .status )
@@ -70,10 +70,12 @@ def test_basic_request(self):
7070 self .assertIsNone (test_span .sy )
7171
7272 self .assertEqual (None , django_span .ec )
73-
7473 self .assertEqual ('/' , django_span .data ["http" ]["url" ])
7574 self .assertEqual ('GET' , django_span .data ["http" ]["method" ])
7675 self .assertEqual (200 , django_span .data ["http" ]["status" ])
76+ self .assertEqual ('test=1' , django_span .data ["http" ]["params" ])
77+ self .assertEqual ('^$' , django_span .data ["http" ]["path_tpl" ])
78+
7779 self .assertIsNone (django_span .stack )
7880
7981 def test_synthetic_request (self ):
@@ -94,6 +96,8 @@ def test_synthetic_request(self):
9496 urllib3_span = spans [1 ]
9597 django_span = spans [0 ]
9698
99+ self .assertEqual ('^$' , django_span .data ["http" ]["path_tpl" ])
100+
97101 self .assertTrue (django_span .sy )
98102 self .assertIsNone (urllib3_span .sy )
99103 self .assertIsNone (test_span .sy )
@@ -115,15 +119,15 @@ def test_request_with_error(self):
115119
116120 filter = lambda span : span .n == 'sdk' and span .data ['sdk' ]['name' ] == 'test'
117121 test_span = get_first_span_by_filter (spans , filter )
118- assert (test_span )
122+ assert (test_span )
119123
120124 filter = lambda span : span .n == 'urllib3'
121125 urllib3_span = get_first_span_by_filter (spans , filter )
122- assert (urllib3_span )
126+ assert (urllib3_span )
123127
124128 filter = lambda span : span .n == 'django'
125129 django_span = get_first_span_by_filter (spans , filter )
126- assert (django_span )
130+ assert (django_span )
127131
128132 assert ('X-INSTANA-T' in response .headers )
129133 assert (int (response .headers ['X-INSTANA-T' ], 16 ))
@@ -156,6 +160,7 @@ def test_request_with_error(self):
156160 self .assertEqual ('GET' , django_span .data ["http" ]["method" ])
157161 self .assertEqual (500 , django_span .data ["http" ]["status" ])
158162 self .assertEqual ('This is a fake error: /cause-error' , django_span .data ["http" ]["error" ])
163+ self .assertEqual ('^cause_error$' , django_span .data ["http" ]["path_tpl" ])
159164 self .assertIsNone (django_span .stack )
160165
161166 def test_request_with_not_found (self ):
@@ -175,8 +180,30 @@ def test_request_with_not_found(self):
175180
176181 filter = lambda span : span .n == 'django'
177182 django_span = get_first_span_by_filter (spans , filter )
178- assert (django_span )
183+ assert (django_span )
184+
185+ self .assertIsNone (django_span .ec )
186+ self .assertEqual (404 , django_span .data ["http" ]["status" ])
187+
188+ def test_request_with_not_found_no_route (self ):
189+ with tracer .start_active_span ('test' ):
190+ response = self .http .request ('GET' , self .live_server_url + '/no_route' )
191+
192+ assert response
193+ self .assertEqual (404 , response .status )
179194
195+ spans = self .recorder .queued_spans ()
196+ spans = drop_log_spans_from_list (spans )
197+
198+ span_count = len (spans )
199+ if span_count != 3 :
200+ msg = "Expected 3 spans but got %d" % span_count
201+ fail_with_message_and_span_dump (msg , spans )
202+
203+ filter = lambda span : span .n == 'django'
204+ django_span = get_first_span_by_filter (spans , filter )
205+ assert (django_span )
206+ self .assertIsNone (django_span .data ["http" ]["path_tpl" ])
180207 self .assertIsNone (django_span .ec )
181208 self .assertEqual (404 , django_span .data ["http" ]["status" ])
182209
@@ -232,6 +259,7 @@ def test_complex_request(self):
232259 self .assertEqual ('/complex' , django_span .data ["http" ]["url" ])
233260 self .assertEqual ('GET' , django_span .data ["http" ]["method" ])
234261 self .assertEqual (200 , django_span .data ["http" ]["status" ])
262+ self .assertEqual ('^complex$' , django_span .data ["http" ]["path_tpl" ])
235263
236264 def test_custom_header_capture (self ):
237265 # Hack together a manual custom headers list
@@ -271,6 +299,7 @@ def test_custom_header_capture(self):
271299 self .assertEqual ('/' , django_span .data ["http" ]["url" ])
272300 self .assertEqual ('GET' , django_span .data ["http" ]["method" ])
273301 self .assertEqual (200 , django_span .data ["http" ]["status" ])
302+ self .assertEqual ('^$' , django_span .data ["http" ]["path_tpl" ])
274303
275304 assert "X-Capture-This" in django_span .data ["http" ]["header" ]
276305 self .assertEqual ("this" , django_span .data ["http" ]["header" ]["X-Capture-This" ])
0 commit comments