8000 Set default timeout of pushgateway actions to 30s by bz2 · Pull Request #237 · prometheus/client_python · GitHub
[go: up one dir, main page]

Skip to content

Set default timeout of pushgateway actions to 30s #237

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

Merged
merged 2 commits into from
Feb 6, 2018

Conversation

bz2
Copy link
Contributor
@bz2 bz2 commented Feb 4, 2018

Explicitly passing None will still trigger the no timeout behaviour of the underlying Python http/socket modules.

This is motived by hitting an odd case in a k8s cluster job where some job pods were hung for 2 hours in the finally-post-metrics step after some cluster unhappiness that had since been resolved. However, I couldn't later reproduce the behaviour locally, as my machine at least does timeout the socket after a reasonable window regardless.

Even so, was worth adapting our application code to set a timeout, and having a sensible default in the client library here also seems reasonable.

Explicitly passing `None` will still trigger the no timeout behaviour
of the underlying Python http/socket modules.
@@ -30,6 +30,11 @@

PYTHON26_OR_OLDER = sys.version_info < (2, 7)

# Default socket timeout for http requests, such as to a pushgateway.
# Note: Setting this after import time will not change the default used.
_REQUEST_TIMEOUT = 30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's be simpler to hardcode it, this is more than enough time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a (pseudo) const is mostly a hint to use a consistent value for anything doing http requests. Can just use literal everywhere if you'd prefer?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer a literal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brian-brazil brian-brazil merged commit 6009899 into prometheus:master Feb 6, 2018
@brian-brazil
Copy link
Contributor

Thanks!

@bz2 bz2 deleted the default_request_timeout branch February 6, 2018 14:37
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

Successfully merging this pull request may close these issues.

2 participants
0