Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Errors in middlewares break fastapi service #659

Open
aguschin opened this issue Apr 26, 2023 · 2 comments
Open

Errors in middlewares break fastapi service #659

aguschin opened this issue Apr 26, 2023 · 2 comments
Labels
bug Something isn't working monitoring Enabling model monitoring - exposing stats to be collected by prometheus and other services p2-medium Medium priority plugins Plugins and extensions for MLEM! serve Serving models

Comments

@aguschin
Copy link
Contributor

Not so long ago, we added Prometheus middleware https://github.com/iterative/mlem/blob/main/mlem/contrib/prometheus.py which can be attached to FastAPI service MLEM is building, processing requests and responses data and exposing /metrics endpoint to be scraped by Prometheus.

It happens, that if code in middleware breaks, the server doesn't return the response. Which is a shame, it still needs to return response in any case. We need to fix this.

Example can be found in https://github.com/aguschin/art-expert-telegram-bot/tree/main/fastapi-deployment:

  • server.mlem has a config example, you can use it to run the service
  • lang_metric.py has middleware metrics code - to reproduce simply make any of them fail (1/0 will suffice)

Setting p2 priority since the feature is not documented and is experimental.

@aguschin aguschin added bug Something isn't working plugins Plugins and extensions for MLEM! p2-medium Medium priority monitoring Enabling model monitoring - exposing stats to be collected by prometheus and other services serve Serving models labels Apr 26, 2023
@aminalaee
Copy link
Contributor

I was checking this out, what do you mean it breaks the service?
While testing I can see the response is returned and also the traceback is displayed, which is a good thing since you don't want to mask the errors in the middlewares.

@aguschin
Copy link
Contributor Author

aguschin commented May 11, 2023

If that behaves like you say, it's how it should be I think @aminalaee. I didn't get normal (status code 200) responses when I was testing this. Experienced that on multiple deployments. I wonder if this is flaky.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working monitoring Enabling model monitoring - exposing stats to be collected by prometheus and other services p2-medium Medium priority plugins Plugins and extensions for MLEM! serve Serving models
Projects
None yet
Development

No branches or pull requests

2 participants