File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ async def __aenter__(self) -> LocustResponse:
107107 await super ().__aenter__ ()
108108 except (ClientConnectorError , ClientResponseError , TimeoutError ) as e :
109109 if request_info := getattr (e , "request_info" , None ):
110- url = request_info .url
110+ url = str ( request_info .url )
111111 else :
112112 url = self .str_or_url
113113 self .span .record_exception (e )
@@ -151,6 +151,7 @@ async def __aexit__(
151151 else :
152152 # wrap plain strings in Exceptions. Callstack may be confusing, but it is better than nothing
153153 self .span .record_exception (Exception (err ))
154+ self .span .set_attribute ("http.status" , str (self ._resp .status ))
154155 context .detach (self ._token )
155156 self .span .end (self .end_time )
156157
Original file line number Diff line number Diff line change @@ -108,6 +108,8 @@ async def run(user):
108108 logger.info("info level log message")
109109 async with user.client.get("http://localhost:8081/") as resp:
110110 pass
111+ async with user.client.get("http://localhost:8081/500") as resp:
112+ pass
111113""" )
112114 proc = await asyncio .create_subprocess_exec (
113115 "aiolocust" ,
@@ -135,9 +137,13 @@ async def run(user):
135137 err = stderr .decode (errors = "replace" )
136138 print (err )
137139 output = stdout .decode (errors = "replace" )
140+ print (output )
138141 assert "warning level log message" in err
139142 assert "info level log message" not in err
140143 assert "exception" not in err .lower ()
144+ # test some span stuff while we are at it
145+ assert '"http.status": "200"' in output
146+ assert '"http.status": "500"' in output
141147 assert await proc .wait () == 0
142148
143149
You can’t perform that action at this time.
0 commit comments