File tree Expand file tree Collapse file tree 3 files changed +185
-0
lines changed
Expand file tree Collapse file tree 3 files changed +185
-0
lines changed Original file line number Diff line number Diff line change 11from fastapi import FastAPI
2+ from fastapi .middleware .cors import CORSMiddleware
3+ from opentelemetry .instrumentation .fastapi import ( # type: ignore[reportMissingTypeStubs]
4+ FastAPIInstrumentor ,
5+ )
26
37from api .dependency_container import DependencyContainer
48from api .workflows .products import product_router
59from common .application_environment import ApplicationEnvironment
610
11+
12+ def add_telemetry (app : FastAPI ) -> None :
13+ FastAPIInstrumentor .instrument_app (app ) # type: ignore[reportUnknownMemberType]
14+
15+
716DependencyContainer .initialize ()
817openapi_url = (
918 "/openapi.json"
1019 if ApplicationEnvironment .get_current () != ApplicationEnvironment .PRODUCTION
1120 else None
1221)
1322app = FastAPI (title = "Python monorepo" , version = "0.1.0" , openapi_url = openapi_url )
23+ app .add_middleware (
24+ CORSMiddleware ,
25+ allow_origins = ["*" ],
26+ allow_credentials = False ,
27+ allow_methods = ["*" ],
28+ allow_headers = ["*" ],
29+ )
1430app .include_router (product_router .router )
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ dependencies = [
88 " common" ,
99 " domain" ,
1010 " fastapi[standard]==0.115.12" ,
11+ " opentelemetry-instrumentation-fastapi==0.54b1" ,
1112 " poethepoet==0.34.0" ,
1213 " pydantic==2.11.4" ,
1314 " pydantic-settings[azure-key-vault]==2.9.1" ,
You can’t perform that action at this time.
0 commit comments