File tree 5 files changed +12
-1
lines changed
5 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 9
9
import torch
10
10
import uvicorn
11
11
from fastapi import FastAPI
12
+ from prometheus_fastapi_instrumentator import Instrumentator
12
13
from sentry_sdk .integrations .fastapi import FastApiIntegration
13
14
from sentry_sdk .integrations .starlette import StarletteIntegration
14
15
from transformers import logging as transformer_logging # type:ignore
@@ -127,6 +128,9 @@ def get_model_app() -> FastAPI:
127
128
128
129
add_onyx_request_id_middleware (application , request_id_prefix , logger )
129
130
131
+ # Initialize and instrument the app
132
+ Instrumentator ().instrument (application ).expose (application )
133
+
130
134
return application
131
135
132
136
Original file line number Diff line number Diff line change 17
17
from fastapi .middleware .cors import CORSMiddleware
18
18
from fastapi .responses import JSONResponse
19
19
from httpx_oauth .clients .google import GoogleOAuth2
20
+ from prometheus_fastapi_instrumentator import Instrumentator
20
21
from sentry_sdk .integrations .fastapi import FastApiIntegration
21
22
from sentry_sdk .integrations .starlette import StarletteIntegration
22
23
from sqlalchemy .orm import Session
@@ -435,6 +436,9 @@ def get_application() -> FastAPI:
435
436
# Ensure all routes have auth enabled or are explicitly marked as public
436
437
check_router_auth (application )
437
438
439
+ # Initialize and instrument the app
440
+ Instrumentator ().instrument (application ).expose (application )
441
+
438
442
return application
439
443
440
444
Original file line number Diff line number Diff line change 49
49
("/auth/oauth/callback" , {"GET" }),
50
50
# anonymous user on cloud
51
51
("/tenants/anonymous-user" , {"POST" }),
52
+ ("/metrics" , {"GET" }), # added by prometheus_fastapi_instrumentator
52
53
]
53
54
54
55
Original file line number Diff line number Diff line change @@ -96,3 +96,4 @@ mistune==0.8.4
96
96
sentry-sdk==2.14.0
97
97
prometheus_client==0.21.0
98
98
fastapi-limiter==0.1.6
99
+ prometheus_fastapi_instrumentator==7.1.0
Original file line number Diff line number Diff line change @@ -15,4 +15,5 @@ uvicorn==0.21.1
15
15
voyageai==0.2.3
16
16
litellm==1.61.16
17
17
sentry-sdk[fastapi,celery,starlette]==2.14.0
18
- aioboto3==13.4.0
18
+ aioboto3==13.4.0
19
+ prometheus_fastapi_instrumentator==7.1.0
You can’t perform that action at this time.
0 commit comments