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 66from dotenv import load_dotenv
77from environs import Env
88from fastapi import FastAPI
9+ from opentelemetry .instrumentation .fastapi import FastAPIInstrumentor
910
1011from .globals import global_storage
1112from .openai_clients import create_openai_chat_client , create_openai_embed_client
@@ -63,6 +64,9 @@ def create_app():
6364
6465 app = FastAPI (docs_url = "/docs" , lifespan = lifespan )
6566
67+ if os .getenv ("APPLICATIONINSIGHTS_CONNECTION_STRING" ):
68+ FastAPIInstrumentor .instrument_app (app )
69+
6670 from . import api_routes # noqa
6771 from . import frontend_routes # noqa
6872
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ dependencies = [
1414 " openai>=1.34.0,<2.0.0" ,
1515 " tiktoken>=0.7.0,<0.8.0" ,
1616 " openai-messages-token-helper>=0.1.5,<0.2.0" ,
17+ " opentelemetry-instrumentation-fastapi>=0.46b0,<1.0.0" ,
1718]
1819
1920[build-system ]
You can’t perform that action at this time.
0 commit comments