Skip to content

Commit 84da950

Browse files
author
Andrei Neagu
committed
refactor
1 parent 2b92ddf commit 84da950

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ def initialize_prometheus_instrumentation(app: FastAPI) -> None:
2222
app.state.prometheus_instrumentator.instrument(app)
2323

2424

25-
def _startup(app: FastAPI) -> None:
25+
async 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

2929

30-
def _shutdown(app: FastAPI) -> None:
30+
async def _shutdown(app: FastAPI) -> None:
3131
assert isinstance(app.state.prometheus_registry, CollectorRegistry) # nosec
3232
registry = app.state.prometheus_registry
3333
for collector in list(registry._collector_to_names.keys()): # noqa: SLF001
@@ -51,6 +51,6 @@ def setup_prometheus_instrumentation(app: FastAPI) -> Instrumentator:
5151
async def lifespan_prometheus_instrumentation(app: FastAPI) -> AsyncIterator[State]:
5252
# NOTE: requires ``initialize_prometheus_instrumentation`` to be called before the
5353
# lifespan of the applicaiton runs, usually rigth after the ``FastAPI`` instance is created
54-
_startup(app)
54+
await _startup(app)
5555
yield {}
56-
_shutdown(app)
56+
await _shutdown(app)

0 commit comments

Comments
 (0)