Skip to content

Commit 2b92ddf

Browse files
author
Andrei Neagu
committed
rename
1 parent 2981bd5 commit 2b92ddf

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

packages/service-library/src/servicelib/fastapi/prometheus_instrumentation.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff 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:
4242
def 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

5751
async 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)

0 commit comments

Comments
 (0)