Skip to content
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

[doc] The demo of 'tls_auth_handler' is not work #874

Closed
karezachen opened this issue Jan 5, 2023 · 3 comments
Closed

[doc] The demo of 'tls_auth_handler' is not work #874

karezachen opened this issue Jan 5, 2023 · 3 comments

Comments

@karezachen
Copy link
Contributor

ENV

tls_auth_handler_demo.py --> code form README.md

from prometheus_client import CollectorRegistry, Gauge, push_to_gateway
from prometheus_client.exposition import tls_handler
def my_auth_handler(url, method, timeout, headers, data):
    certfile = 'client-crt.pem'
    keyfile = 'client-key.pem'
    return tls_auth_handler(url, method, timeout, headers, data, certfile, keyfile)
registry = CollectorRegistry()
g = Gauge('job_last_success_unixtime', 'Last time a batch job successfully finished', registry=registry)
g.set_to_current_time()
push_to_gateway('localhost:9091', job='batchA', registry=registry, handler=my_auth_handler)
python tls_auth_handle_demo.py

LOG

Traceback (most recent call last):
  File "/private/tmp/tls_auth_handler_demo.py", line 2, in <module>
    from prometheus_client.exposition import tls_handler
ImportError: cannot import name 'tls_handler' from 'prometheus_client.exposition' (/private/tmp/venv/lib/python3.9/site-packages/prometheus_client/exposition.py)

SHOULD BE

from prometheus_client.exposition import tls_handler

update to

from prometheus_client.exposition import tls_auth_handler
@karezachen karezachen changed the title [doc] tls_auth_handler demo not work [doc] tls_auth_handler demo is not work Jan 5, 2023
@karezachen karezachen changed the title [doc] tls_auth_handler demo is not work [doc] The demo of 'tls_auth_handler' is not work Jan 5, 2023
@csmarchbanks
Copy link
Member

Good catch, would you like to open a PR to fix this?

@karezachen
Copy link
Contributor Author

Yes, please check it.

@karezachen karezachen reopened this Jan 9, 2023
@csmarchbanks
Copy link
Member

Fixed in #876

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

No branches or pull requests

2 participants