File tree Expand file tree Collapse file tree 1 file changed +4
-10
lines changed
packages/service-library/src/servicelib/fastapi Expand file tree Collapse file tree 1 file changed +4
-10
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ def initialize_prometheus_instrumentation(app: FastAPI) -> None:
2222 app .state .prometheus_instrumentator .instrument (app )
2323
2424
25- def _setup (app : FastAPI ) -> None :
25+ def _startup (app : FastAPI ) -> None :
2626 assert isinstance (app .state .prometheus_instrumentator , Instrumentator ) # nosec
2727 app .state .prometheus_instrumentator .expose (app , include_in_schema = False )
2828
@@ -42,21 +42,15 @@ def get_prometheus_instrumentator(app: FastAPI) -> Instrumentator:
4242def setup_prometheus_instrumentation (app : FastAPI ) -> Instrumentator :
4343 initialize_prometheus_instrumentation (app )
4444
45- async def _on_startup () -> None :
46- _setup (app )
47-
48- def _unregister () -> None :
49- _shutdown (app )
50-
51- app .add_event_handler ("startup" , _on_startup )
52- app .add_event_handler ("shutdown" , _unregister )
45+ app .add_event_handler ("startup" , _startup )
46+ app .add_event_handler ("shutdown" , _shutdown )
5347
5448 return get_prometheus_instrumentator (app )
5549
5650
5751async def lifespan_prometheus_instrumentation (app : FastAPI ) -> AsyncIterator [State ]:
5852 # NOTE: requires ``initialize_prometheus_instrumentation`` to be called before the
5953 # lifespan of the applicaiton runs, usually rigth after the ``FastAPI`` instance is created
60- _setup (app )
54+ _startup (app )
6155 yield {}
6256 _shutdown (app )
You can’t perform that action at this time.
0 commit comments