Add handler parameter to pushgateway functions to permit HTTP AUTH etc.#120
Closed
tim-seoss wants to merge 4 commits intoprometheus:masterprometheus/client_python:masterfrom
Closed
Add handler parameter to pushgateway functions to permit HTTP AUTH etc.#120tim-seoss wants to merge 4 commits intoprometheus:masterprometheus/client_python:masterfrom
tim-seoss wants to merge 4 commits intoprometheus:masterprometheus/client_python:masterfrom
Conversation
Allow a custom handler to be provided, so that the caller can provide code which carried out basic auth, https client certificate validation or other arbitrary schemes and access methods such as using different types of proxy.
Provide pydoc for the new handler function to the various pushgateway functions, provide parameter descriptions in the documentatation for the push_to_gateway function to avoid excessive copy-and-paste.
Contributor
Author
|
Bah, trying to rush it at the end of the day. Will fix Sunday if I get a chance. Sorry for the noise, please ignore for now... |
| raise IOError("error talking to pushgateway: {0} {1}".format( | ||
| resp.code, resp.msg)) | ||
| else: | ||
| handler(url=url, method=lambda: method, timeout=timeout, |
Contributor
There was a problem hiding this comment.
Why is there a lambda for the method?
| will be carried out by a default handler. | ||
| If not None, the argument must be a function which accepts | ||
| the following arguments: | ||
| url, method, timeout, headers, and content |
Contributor
There was a problem hiding this comment.
It'd be good to include an example one doing something simple like basic auth
rossigee
reviewed
Jan 14, 2017
| raise IOError("error talking to pushgateway: {0} {1}".format( | ||
| resp.code, resp.msg)) | ||
| if handler is None: | ||
| resp = build_opener(handler).open(request, timeout=timeout) |
Contributor
There was a problem hiding this comment.
That's changed HTTPHandler to handler, which will be None. Is this correct?
Contributor
There was a problem hiding this comment.
That looks off alright. Can you send a PR?
Contributor
|
Superseded by #126 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First stab at a handler implementation. No tests yet, please let me know what you think. Documenting a BASIC AUTH handler would probably be a good idea as per #60