prometheus-fastapi-instrumentator
prometheus-fastapi-instrumentator copied to clipboard
Unexpected print in Middleware
Hello) I found the print in library code: https://github.com/trallnag/prometheus-fastapi-instrumentator/blob/673b922e97a4e943a0e4d23db7767015e4c751dd/prometheus_fastapi_instrumentator/middleware.py#L80 Can you pls remove it or allow some customization of this behavior?)
I noticed this as well, and would like to second its removal. 😅
In the meantime for anyone else whose logs are being cluttered up by this, you can silence it by applying this patch somewhere before the instrumentor is actually called:
import prometheus_fastapi_instrumentator as pfi
import prometheus_fastapi_instrumentator.middleware
# Patch the Prometheus instrumentor to stop
# it from `print()`ing to stdout
pfi.middleware.print = lambda *_, **__: None
It's hacky, but it works and is safe.
Fixed in #157. Will be released soon(tm)