-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
#277 Add the ability to specify request timeouts #280
base: master
Are you sure you want to change the base?
Conversation
@FRosner Could you please add a couple of unit tests for this change? |
Sure @4n4nd! Do you have a pointer for me on which file to add this to? Do you have any tests that simulate making requests to Prom where I can add a case that times out? |
@FRosner You could add a test to https://github.com/4n4nd/prometheus-api-client-python/blob/master/tests/test_prometheus_connect.py |
Thanks! I got distracted a bit. I will try to get to this by next week. |
Sorry, I'm back after a bit. I looked into the test and it seems I have to bring my own Prometheus? Is there a specific reason you are not using testcontainers? Either way, do you have a preference on how I can delay the response so that I hit a timeout? A mock server? Toxy proxy? |
@FRosner you can see how we are testing other functions here using a mocked network. In addition to that, we use this public prometheus instance to run some of our tests. You can basically execute the following command to run the test suite: |
I respect check have to be passed, but for anyone who is searching for a quick solution i will provide a fork that adds an addtional request_args parameter to every function. This solution is not perfect at all, because the parameters get parsed differently on different levels and functions, but i thought i could may help someone in special cases. UsageJust put the additional parameters into the request_args parameter. These kwargs get mostly passed to requests.Session.request
request_args argument equals **kwargs in the named method. Installation
|
Summary
I am adding the ability to configure request timeouts.
Details
References