You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

20 lines
644 B

import http.server
from prometheus_client import start_http_server
from prometheus_client import Counter
REQUESTS=Counter('hello_worlds_total', 'hellow worlds requested.')
EXCEPTIONS=Counter("hello_world_exceptions_total", 'exceptions serving hello world.')
class MyHandler(http.server.BaseHTTPRequestHandler):
@EXCEPTIONS.count_exceptions()
def do_GET(self):
REQUESTS.inc()
self.send_response(200)
self.end_headers()
self.wfile.write(b"hello world")
if __name__ == "__main__":
start_http_server(8000)
server = http.server.HTTPServer(('localhost', 8001), MyHandler)
server.serve_forever()