Closed
Description
If you have a custom collector registered, and that collector exceptions, then the client produces a 200 with no metrics; not even the build in ones.
#!/usr/bin/python3
import time
from prometheus_client import start_http_server
from prometheus_client.core import REGISTRY
class CustomCollector(object):
def collect(self):
raise Exception('bang')
REGISTRY.register(CustomCollector())
start_http_server(23456)
while True:
time.sleep(1e9)
% curl -v http://localhost:23456/
* Trying ::1...
* connect to ::1 port 23456 failed: Connection refused
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 23456 (#0)
> GET / HTTP/1.1
> Host: localhost:23456
> User-Agent: curl/7.47.0
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: BaseHTTP/0.6 Python/3.5.1+
< Date: Thu, 16 Jun 2016 09:18:40 GMT
< Content-Type: text/plain; version=0.0.4; charset=utf-8
<
* Closing connection 0
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 43974)
Traceback (most recent call last):
File "/usr/lib/python3.5/socketserver.py", line 313, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python3.5/socketserver.py", line 341, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python3.5/socketserver.py", line 354, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python3.5/socketserver.py", line 681, in __init__
self.handle()
File "/usr/lib/python3.5/http/server.py", line 415, in handle
self.handle_one_request()
File "/usr/lib/python3.5/http/server.py", line 403, in handle_one_request
method()
File "/home/faux/code/client_python/prometheus_client/exposition.py", line 76, in do_GET
self.wfile.write(generate_latest(core.REGISTRY))
File "/home/faux/code/client_python/prometheus_client/exposition.py", line 55, in generate_latest
for metric in registry.collect():
File "/home/faux/code/client_python/prometheus_client/core.py", line 54, in collect
for metric in collector.collect():
File "err.py", line 10, in collect
raise Exception('bang')
Exception: bang
----------------------------------------
I believe this should either return a 500, or return the rest of the metrics, with this missing, or the rest of the metrics and a client_generation_errors{collector="CustomCollector"} 1
, or...
Metadata
Metadata
Assignees
Labels
No labels