We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents b6b7c85 + 4873b90 commit 6036f7fCopy full SHA for 6036f7f
app/main.py
@@ -1,8 +1,21 @@
1
from fastapi import FastAPI
2
+from prometheus_fastapi_instrumentator import Instrumentator
3
+import prometheus_client as prom
4
+import time
5
6
import os
7
8
app = FastAPI()
9
+Instrumentator().instrument(app)
10
+
11
+prom.start_http_server(9090)
12
13
+@app.get("/ping")
14
+def test():
15
+ if int(time.time()) % 3 == 0:
16
+ raise Exception("unknown internal error")
17
18
+ return {"pong": True}
19
20
@app.get("/")
21
def read_root():
requirements.txt
@@ -1,3 +1,4 @@
fastapi~=0.103
uvicorn~=0.23
-httpx
+httpx
+prometheus-fastapi-instrumentator
0 commit comments