Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

See what request generated a failure #103

Closed
gkristjansson opened this issue Oct 28, 2013 · 13 comments
Closed

See what request generated a failure #103

gkristjansson opened this issue Oct 28, 2013 · 13 comments

Comments

@gkristjansson
Copy link

It would be very to nice to able to see what http request generated a failure. It also would be useful to include the payload that was sent with the request.

@Jahaja
Copy link
Member

Jahaja commented Oct 28, 2013

Indeed, this has been on the todo list for a while. If time allows, I'll see if I can get this sorted once and for all.

@heyman
Copy link
Member

heyman commented Oct 28, 2013

I agree. We just have to make sure to use sampling of data, so that we don't end up using up all bandwidth when running Locust distributed with a lot of slaves.

@gkristjansson
Copy link
Author

About the number of samples, one of the issues that I have found is that the app I am load testing uses lot of unique urls, which makes the web interface heavy to load, or even impossible

@Jahaja
Copy link
Member

Jahaja commented Oct 28, 2013

You can name your requests using the name parameter to .get(), .post() etc.

l.get("/profile/%d" % user_id, name="/profile/[user-id]")

@Alerion
Copy link

Alerion commented Jan 30, 2015

You can use Event hooks, like:

from locust.events import request_failure

def on_failure(request_type, name, response_time, exception, **kwargs):
    print exception.request.url
    print exception.response.status_code
    print exception.response.content

request_failure += on_failure

@ghost
Copy link

ghost commented Aug 4, 2015

The above is an excellent debugging tip.

@BenjamenMeyer
Copy link

perhaps something like https://github.com/BenjamenMeyer/locust/tree/enhancement_track_responses would be good? It's more specific to an API that I'm developing, but it could probably be generalized by making the 'transaction-id' header field name a configuration variable.

@cyberw
Copy link
Collaborator

cyberw commented Oct 18, 2019

If it isnt already in there, we should add @Alerion ’s suggestion to the documentation. Closing this.

@cyberw cyberw closed this as completed Oct 18, 2019
@rokcarl
Copy link

rokcarl commented Apr 7, 2020

Now in master it doesn't work, probably the API is changed and the API docs are not yet up-to-date. I get:

TypeError: unsupported operand type(s) for +=: 'EventHook' and 'function'

@heyman
Copy link
Member

heyman commented Apr 7, 2020

The docs are up to date here: https://docs.locust.io/en/latest/api.html#event-hooks
(you linked to the latest stable docs).

@rokcarl
Copy link

rokcarl commented Apr 7, 2020

Ah, my bad, thank you!

@Anu35
Copy link

Anu35 commented Sep 2, 2020

Hi All

I got "TypeError: unsupported operand type(s) for +=: 'EventHook' and 'function'" I solved it by adding locust.events to requests.

Then now I am getting new error
Traceback (most recent call last):
File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python38\Lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python38\Lib\runpy.py", line 86, in run_code
exec(code, run_globals)
File "C:\Users\xxxxxx\xxxxx\venv\Scripts\locust.exe_main
.py", line 7, in
File "c:\users\xxxxxxx\xxxx\venv\lib\site-packages\locust\main.py",
line 133, in main
options = parse_options()
File "c:\users\xxxxx\xxxx\venv\lib\site-packages\locust\argument_parser.py", line 442, in parse_options
parser = get_parser()
File "c:\users\xxxxx\xxxxxx\venv\lib\site-packages\locust\argument_parser.py", line 437, in get_parser
locust.events.init_command_line_parser.fire(parser=parser)
AttributeError: module 'locust.events' has no attribute 'init_command_line_parser'

I am using all latest version python --3.8
PIP -20.0.2
Locust --1.2.3

Can you please help fix this error what eactly is reason for this error and what package needs to be updated.

@ajorgeg21
Copy link

I have the same error, how can I solve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants