File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
instrumentation/opentelemetry-instrumentation-aiohttp-server
src/opentelemetry/instrumentation/aiohttp_server Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -244,12 +244,12 @@ def get_default_span_name(request: web.Request) -> str:
244244 Returns:
245245 The span name.
246246 """
247- span_name = request .path .strip () or f"HTTP { request . method } "
247+ path = request .path .strip ()
248248 if request .match_info and request .match_info .route .resource :
249249 resource = request .match_info .route .resource
250250 if resource .canonical :
251- span_name = resource .canonical
252- return span_name
251+ path = resource .canonical
252+ return f" { request . method } { path } "
253253
254254
255255def _get_view_func (request : web .Request ) -> str :
Original file line number Diff line number Diff line change @@ -181,17 +181,17 @@ async def test_status_code_instrumentation(
181181
182182@pytest .mark .asyncio
183183@pytest .mark .parametrize (
184- "url , example_paths" ,
184+ "span_name , example_paths" ,
185185 [
186186 (
187- "/test-path/{url_param}" ,
187+ "GET /test-path/{url_param}" ,
188188 (
189189 "/test-path/foo" ,
190190 "/test-path/bar" ,
191191 ),
192192 ),
193193 (
194- "/object/{object_id}/action/{another_param}" ,
194+ "GET /object/{object_id}/action/{another_param}" ,
195195 (
196196 "/object/1/action/bar" ,
197197 "/object/234/action/baz" ,
@@ -203,7 +203,7 @@ async def test_url_params_instrumentation(
203203 tracer ,
204204 server_fixture ,
205205 aiohttp_client ,
206- url ,
206+ span_name ,
207207 example_paths ,
208208):
209209 _ , memory_exporter = tracer
@@ -220,7 +220,7 @@ async def test_url_params_instrumentation(
220220 for request_path , span in zip (
221221 example_paths , memory_exporter .get_finished_spans ()
222222 ):
223- assert url == span .name
223+ assert span_name == span .name
224224 assert request_path == span .attributes [HTTP_TARGET ]
225225 full_url = f"http://{ server .host } :{ server .port } { request_path } "
226226 assert full_url == span .attributes [HTTP_URL ]
You can’t perform that action at this time.
0 commit comments