Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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
tim-seoss:mastertim-seoss/client_python:masterCopy head branch name to clipboard
Closed

Add handler parameter to pushgateway functions to permit HTTP AUTH etc.#120
tim-seoss wants to merge 4 commits intoprometheus:masterprometheus/client_python:masterfrom
tim-seoss:mastertim-seoss/client_python:masterCopy head branch name to clipboard

Conversation

@tim-seoss
Copy link
Contributor

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

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.
@tim-seoss
Copy link
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,
Copy link
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be good to include an example one doing something simple like basic auth

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

That's changed HTTPHandler to handler, which will be None. Is this correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

That looks off alright. Can you send a PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sent in PR #126.

@brian-brazil
Copy link
Contributor

Superseded by #126

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.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.