Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gunicorn worker (uvicorn.workers.UvicornWorker) does not report request/s via statsd client #610

Closed
sileht opened this issue Apr 4, 2020 · 4 comments

Comments

@sileht
Copy link

sileht commented Apr 4, 2020

Hi,

gunicorn worker (uvicorn.workers.UvicornWorker) does not report request/s via statsd client, like other gunicorn workers.

Regards,
Mehdi

Important

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@Traktormaster
Copy link

Hi!

I've just ran into this issue myself. After delving a bit into the codes of gunicorn and uvicorn, I can say the problem is simple, but not very trivial to fix.

The gunicorn statsd implementation is mixed with their logging facility. Which is a a little questionable, no wonder they have an issue to refactor it. Since uvicorn has its own logging system and does not reuse the logger instance from gunicorn (even though it inherits it by forking), the statsd codes are never invoked.

I could not find an easy and nice way to make it work. The worker.log object would need to be accessible from the running http protocol, and even then the statsd logging could not be reused as-is since it's merged with the real logging. (it could lead to logging twice I think)

Anyways, depending on what you're using this can be circumvented in the framework level. I'm using Starlette and there is an ASGI middleware to send request metrics to statsd.

I know this is not a solution, but I wanted to write it down for future reference. Maybe someone will find it useful.

@sandys
Copy link

sandys commented Mar 17, 2021

im facing the same issue here. is there a workaround ? we are using fastapi

@damluji
Copy link

damluji commented Aug 25, 2021

Any updates please? ran into the same problem today.

@Kludex Kludex added this to the Version 0.22.0 milestone Nov 1, 2022
wmfgerrit pushed a commit to wikimedia/mediawiki-services-machinetranslation that referenced this issue Dec 20, 2023
The gunicorn statsd reporting does not work with custom
worker class. So let the API handler report each requests.
The statsd key for this would be "machinetranslation.requests"

See encode/uvicorn#610

Change-Id: I15be8fbc5f686bf5f3dc911516a473f7c6f56f53
@Kludex
Copy link
Sponsor Member

Kludex commented Apr 13, 2024

Given that Gunicorn has the issue benoitc/gunicorn#1564, and we are deprecating the workers within Uvicorn (#2302).

@Kludex Kludex closed this as completed Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants