Comments (7)
Hi again,
sorry again for my late response to this issue.
I've just checked the code, and found that GrafanaApi()
already obtains an argument timeout
, which unfortunately defaults to 5 seconds. I agree with Mikhail that this should also be available as an argument to from_url()
, amongst other improvements in the same area, and - most importantly - this option should have proper documentation, right?
In the meanwhile, and with any current release of grafana-client
, before running any requests, you should be able to do this:
# Create Grafana API wrapper instance, and set timeout.
grafana = GrafanaApi.from_url("https://username:[email protected]/grafana/")
grafana.client.timeout = 60
Let me know if that helps you already, so I can handle that with a corresponding priority if it is still a pain, or if that workaround will fit your needs already. Apologies, Mikhail, for missing that detail because I did not have a look at the code yet at the time I was responding to you.
With kind regards,
Andreas.
from grafana-client.
Hi @amotl ,
yes absolutely thanks for your work on this!
from grafana-client.
Dear Mikhail,
thanks a stack for suggesting this. We will bring it in on the next development iteration. Patches are always welcome.
With kind regards,
Andreas.
from grafana-client.
Thanks for your work. This feature is important for us as well. Sometimes Grafana needs >5s to create a dashboard.
from grafana-client.
For the improvements to the implementation, when they will be conducted, I would like to leave this note here, in order to pick up corresponding guidelines quickly, without needing to research them again. Also, to eventually receive any comments about it.
Recap
- The current default timeout of 5 seconds is unfortunate.
- As a workaround, timeout options can be adjusted by using the
GrafanaClient
object'stimeout
attribute. It is a bit awkward, so that interface should be improved.
# Create Grafana API wrapper instance, and set timeout.
grafana = GrafanaApi.from_url("https://username:[email protected]/grafana/")
grafana.client.timeout = 60
Proposal
- The future implementation may just use the defaults of the underlying HTTP library,
urllib3
1. There is also excellent documentation about this topic at 2. Following theurllib3
implementation, the new default timeout value will implicitly usesocket.getdefaulttimeout()
, which isNone
by default, at least on my machine. Effectively, this would mean "infinite" timeout by default. - Adjusting timeout values (total vs. connect vs. read) should also fit into the convenience factory methods
from_url()
andfrom_env()
.
Footnotes
from grafana-client.
Choosing sensible default timeout values. 5 seconds, it is.
To contradict my previous statement, I think grafana-client
should keep sensible default values for the HTTP timeout options, following the recommendation of the requests
authors.
Most requests to external servers should have a timeout attached, in case the server is not responding in a timely manner. By default, requests do not time out unless a timeout value is set explicitly. Without a timeout, your code may hang for minutes or more. 1
I think following HTTPX' recommendations would be a reasonable approach.
HTTPX defaults to including reasonable timeouts for all network operations, meaning that if a connection is not properly established then it should always raise an error rather than hanging indefinitely. The default timeout for network inactivity is five seconds. 2
requests
also presents this code example at the first place. So, it can indeed be considered as a recommendation.
requests.get('https://github.com', timeout=5)
Effectively, this would mean the default timeout value does not change at all, will be 5 seconds as before, but its configuration interface will be more friendly, and documentation will be improved. Do you have any objections?
Footnotes
from grafana-client.
Hi again,
a few improvements have been made with GH-99, and released on behalf of version 3.6.0. Do you think this will satisfy your needs? You can find a corresponding documentation snippet at 1.
With kind regards,
Andreas.
Footnotes
from grafana-client.
Related Issues (20)
- Improve test suite by adding integration tests with Grafana HOT 1
- Add x-disable-provenance header to allow alert rules to be edited from the UI HOT 7
- Field `database` in data source model will be deprecated HOT 1
- grafana_client.client.GrafanaClientError: Client Error 404: Not found HOT 8
- Grafana Smart Query Prometheus missing key HOT 6
- Need support for following missing api HOT 4
- Dashboard.get_dashboard_by_name seems broken HOT 5
- Plugins: Add more filtering capabilities to `list()` method HOT 1
- Cannot update datasource key with newlines, e.g. GCP Monitoring HOT 1
- distutils.version.LooseVersion is deprecated HOT 3
- Feature: Organisation-awareness HOT 7
- feature request: async api HOT 7
- Service Account functionality HOT 7
- New version of Grafana API create-annotation adds dashboardUID field HOT 2
- Grafana 10.2.3: breaking changes HOT 5
- Missing parentUid for create_folder HOT 6
- User Teams API endpoint missing HOT 3
- Get all folders endpoint is incorrect HOT 1
- Dashboard Search API endpoint is incorrect HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grafana-client.