locustio / locust

Write scalable load tests in plain Python 🚗💨
https://locust.cloud
MIT License
25.09k stars 3k forks source link

Error Logging in FastHttpUser #2937

Open cyberw opened 1 month ago

cyberw commented 1 month ago

Discussed in https://github.com/orgs/locustio/discussions/2936

Originally posted by **swaalt** October 10, 2024 Hi, I am using FastHttpUser and when I receive a 404 the fail is registered like this, this happens because the geventhttpclient saves in the exception the badstatuscode text the url of the request I made, which is dynamic and appears separated by each one, I need that either I take the “name” or simply do not place anything, just place the badstatuscode 404, can this be addressed with the locust as it is now or do I have to modify something? ![fails](https://github.com/user-attachments/assets/92b13451-f29c-4c8c-a42c-7f1678380deb)
cyberw commented 1 month ago

PR:s welcome (I'll look at it myself, but no guarantees on the timing)

jayantp2003 commented 1 month ago

I would like to work on this issue. Please assign me this issue.

cyberw commented 1 month ago

Ideally, make it work the same as HttpUser.

swaalt commented 1 month ago

I made this change to make the URL parameter optional by modifying the repository for geventhttpuser, then modified the use of that class in the Locust repository by removing the use of the url parameter in the "LocustUserAgent" class in fasthttp.py.

geventhttpclient:https://github.com/swaalt/geventhttpclient/commit/94253d42d6c33f0c09fadd82ecf1821f81dbaf59

fasthttp:https://github.com/swaalt/locust/commit/ef4d4c3188985fb461cc5a0604fe89a3e5e8a12f

cyberw commented 1 month ago

Interesting. But maybe even better/easier to subclass the ConnectionError class (in locust) and override the __repr__ method there? Such a PR would be most welcome!

swaalt commented 1 month ago

Would that be okay? https://github.com/swaalt/locust/commit/c9192ac0a0ec7a58c70d57b5bc112b3c7e9f9152

cyberw commented 1 month ago

Looks great! PR it? Maybe add a test case for it? (ignore any other errors, the tests are a bit flaky atm)

swaalt commented 1 month ago

Attach the PR : https://github.com/locustio/locust/pull/2944