Skip to content

Set default timeout of pushgateway actions to 30s - #237

Merged
brian-brazil merged 2 commits into
prometheus:masterfrom
bz2:default_request_timeout
Feb 6, 2018
Merged

brian-brazil merged 2 commits into
prometheus:masterfrom
bz2:default_request_timeout

Conversation

@bz2

@bz2 bz2 commented Feb 4, 2018

Copy link
Copy Markdown
Contributor

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.
Comment thread prometheus_client/exposition.py Outdated

# 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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