Feature Request: Cause requests to be ignored from stats collection
See original GitHub issueI’d like to be able to annotate some requests to be ignored from collection in stats.
(The use case is that we have to create/delete models during setup and teardown, and since we don’t have access to the DB this has to be done through the API. These requests shouldn’t show up in the stats at the end. I know it doesn’t make sense to ignore these since they’re part of the “lifecycle” of the task set, but that’s the ask.)
Here’s what I’ve got so far:
IGNORE_REQUEST = False
def conditional_request_success(*args, **kwargs):
if not IGNORE_REQUEST:
return on_request_success(*args, **kwargs)
def conditional_request_failure(*args, **kwargs):
if not IGNORE_REQUEST:
return on_request_failure(*args, **kwargs)
events.request_success -= on_request_success
events.request_success += conditional_request_success
events.request_failure -= on_request_failure
events.request_failure += conditional_request_failure
class IgnoreRequestContextManager(object):
def __enter__(self):
global IGNORE_REQUEST
IGNORE_REQUEST = True
def __exit__(self, *args, **kwargs):
global IGNORE_REQUEST
IGNORE_REQUEST = False
ignore_request = IgnoreRequestContextManager
And then I can:
def setup(self):
with ignore_request():
self.login()
self.create_setup_models()
...
This is obviously not thread-safe of course. I can update it to use threadlocals, but is this the best way to go about this in the absence of an official feature?
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Block preferences: "Not Renewable - Item has Requests" is ...
Description. We activated the rule "Not renewable - Item has requests" in the block preferences but it appears to be ignored.
Read more >Wikipedia:Ignored feature requests
You can discuss them first at m:MediaWiki feature request and bug report discussion. ... and is explicitly not for the requesting of new...
Read more >12 Managing Optimizer Statistics: Basic Topics
Set the STATISTICS_LEVEL initialization level to BASIC to disable collection of all advisories and statistics, including Automatic SQL Tuning Advisor. Note:.
Read more >Customer Feature Requests - Zoho Cares
A request (and even a bug) should be a common item that can be attached to multiple customers. In this way, when we...
Read more >Configuring sampling rules - AWS X-Ray
Sampling rules tell the X-Ray SDK how many requests to record for a set of criteria. By default, the X-Ray SDK records the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Could you make the HTTP requests - that you don’t want to track stats for - with just Requests (or some other client), instead of using the Locust client? Something like:
Alternatively, you could reset all the stats once the setup has completed (though that method wouldn’t work well if you want to exclude tear down requests that are made after the requests that you want to track):
Closing due to lack of activity. Feel free to reopen if this is important to you.