File tree Expand file tree Collapse file tree 2 files changed +5
-0
lines changed Expand file tree Collapse file tree 2 files changed +5
-0
lines changed Original file line number Diff line number Diff line change 6
6
from dotenv import load_dotenv
7
7
from environs import Env
8
8
from fastapi import FastAPI
9
+ from opentelemetry .instrumentation .fastapi import FastAPIInstrumentor
9
10
10
11
from .globals import global_storage
11
12
from .openai_clients import create_openai_chat_client , create_openai_embed_client
@@ -63,6 +64,9 @@ def create_app():
63
64
64
65
app = FastAPI (docs_url = "/docs" , lifespan = lifespan )
65
66
67
+ if os .getenv ("APPLICATIONINSIGHTS_CONNECTION_STRING" ):
68
+ FastAPIInstrumentor .instrument_app (app )
69
+
66
70
from . import api_routes # noqa
67
71
from . import frontend_routes # noqa
68
72
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ dependencies = [
14
14
" openai>=1.34.0,<2.0.0" ,
15
15
" tiktoken>=0.7.0,<0.8.0" ,
16
16
" openai-messages-token-helper>=0.1.5,<0.2.0" ,
17
+ " opentelemetry-instrumentation-fastapi>=0.46b0,<1.0.0" ,
17
18
]
18
19
19
20
[build-system ]
You can’t perform that action at this time.
0 commit comments