File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed
packages/service-library/src/servicelib/fastapi Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ def _startup(tracing_settings: TracingSettings, service_name: str) -> None:
101101 span_processor = BatchSpanProcessor (otlp_exporter )
102102 global_tracer_provider .add_span_processor (span_processor )
103103
104+ FastAPIInstrumentor ().instrument ()
104105 if HAS_AIOPG :
105106 with log_context (
106107 _logger ,
@@ -147,6 +148,7 @@ def _startup(tracing_settings: TracingSettings, service_name: str) -> None:
147148
148149def _shutdown () -> None :
149150 """Uninstruments all opentelemetry instrumentors that were instrumented."""
151+ FastAPIInstrumentor ().uninstrument ()
150152 if HAS_AIOPG :
151153 try :
152154 AiopgInstrumentor ().uninstrument ()
@@ -189,13 +191,9 @@ def setup_tracing(
189191
190192 _startup (tracing_settings = tracing_settings , service_name = service_name )
191193
192- def _on_startup () -> None :
193- FastAPIInstrumentor ().instrument_app (app )
194-
195194 def _on_shutdown () -> None :
196195 _shutdown ()
197196
198- app .add_event_handler ("startup" , _on_startup )
199197 app .add_event_handler ("shutdown" , _on_shutdown )
200198
201199
@@ -208,7 +206,7 @@ def get_tracing_instrumentation_lifespan(
208206 async def tracing_instrumentation_lifespan (
209207 app : FastAPI ,
210208 ) -> AsyncIterator [State ]:
211- FastAPIInstrumentor (). instrument_app ( app )
209+ assert app # nosec
212210
213211 yield {}
214212
You can’t perform that action at this time.
0 commit comments