locust icon indicating copy to clipboard operation
locust copied to clipboard

Error Logging in FastHttpUser

Open cyberw opened this issue 1 year ago β€’ 8 comments

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

cyberw avatar Oct 10 '24 18:10 cyberw

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

cyberw avatar Oct 10 '24 18:10 cyberw

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

jayantp2003 avatar Oct 10 '24 21:10 jayantp2003

Ideally, make it work the same as HttpUser.

cyberw avatar Oct 12 '24 07:10 cyberw

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

swaalt avatar Oct 15 '24 21:10 swaalt

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!

cyberw avatar Oct 16 '24 15:10 cyberw

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

swaalt avatar Oct 16 '24 19:10 swaalt

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

cyberw avatar Oct 16 '24 20:10 cyberw

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

swaalt avatar Oct 16 '24 21:10 swaalt