-
Notifications
You must be signed in to change notification settings - Fork 3k
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
the event request_success should pass request and response to the listener #1413
Comments
That wouldn't work when using Locust to load test non-HTTP stuff. I'd recommend to either create a custom client, or wrap the client calls instead. |
At least, we could put them into the optional arguments: @events.request_success.add_listener
def my_success_handler(request_type, name, response_time, response_length, **kw):
if 'request' in kw:
print('request:', kw['request'])
if 'response' in kw:
print('response:', kw['response'])
print("Successfully made a request to: %s" % name) |
That's a possibility. The only issue I see with that is that people would start relying on their existence and all of a sudden we've crippled support for non-HTTP stuff in practice. Not sure if it would be worth it - maybe? |
Was also looking for a way to access the request and response in the listener. Any chances this will be possible? On a similar idea, is it possible to access the |
The from locust import events
@events.init.add_listener
def _(environment, **kwargs):
@events.request_success.add_listener
def _(**kw):
print("Current user count:", environment.runner.user_count) |
Hi, I support this idea as well, it would be very handy to have request/response at disposal. I would like to be able to access status code for enhanced reporting from listener. Do we have any final decision on this already? |
I like the idea and will happily merge it, but someone else needs to write the code and some test cases :) |
@cyberw btw is it actually a good idea to pass whole request and response from the performance perspective? My use case could be easily covered by adding hostname and status_code for now:
|
(ignore my first, now deleted, response. I was on mobile and confused on which ticket this was) Passing the response body as a string (which might not otherwise even be read into Python unless the user asks for it) would be a big no-no for performance, but passing the response object (same as we are passing to the I’d also like to pass the User object. Tbh, I’m not super worried about other protocols not suppling these values, but we should definitely mention it in our ”new client”-example in the docs. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
Fixed in 1.5.0 #1750 (except for the request) |
Is your feature request related to a problem? Please describe.
I want to fetch the headers of request or response when a request is successful.
Describe the solution you'd like
Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: