From 1b1f118bc34712131a9788050797354a5d66db63 Mon Sep 17 00:00:00 2001 From: Chandramouli S <64595758+Chandru-21@users.noreply.github.com> Date: Fri, 28 Jun 2024 13:37:10 +0530 Subject: [PATCH] adding instrumentator in fastapi --- main.py | 7 +++++-- requirements.txt | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 00ab622..54c363b 100644 --- a/main.py +++ b/main.py @@ -11,7 +11,7 @@ import io import boto3 from datetime import datetime - +from prometheus_fastapi_instrumentator import Instrumentator def upload_to_s3(file_content, filename): s3 = boto3.client('s3') @@ -136,4 +136,7 @@ async def batch_predict(file: UploadFile = File(...)): if __name__== "__main__": - uvicorn.run(app, host="0.0.0.0",port=8005) \ No newline at end of file + uvicorn.run(app, host="0.0.0.0",port=8005) + + +Instrumentator().instrument(app).expose(app) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index d4f90f2..d002b36 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,4 +12,5 @@ gunicorn==21.2.0 hyperopt==0.2.7 mlflow==2.13.2 xgboost==2.0.3 -python-multipart==0.0.9 \ No newline at end of file +python-multipart==0.0.9 +prometheus_fastapi_instrumentator