aio-libs / aio-libs/aiohttp

Gunicorn and StatsD metrics

Đang mở
#3,777 11 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Python
Star
16.5k
Fork
2.4k
Merge trung bình
17 giờ 22 phút
Pull request đã merge (30 ngày)
212

Mô tả

## Long story short

Hi,

Gunicorn provides an optional instrumentation of the arbiter and workers using the StatsD protocol. Details can be found at https://docs.gunicorn.org/en/latest/instrumentation.html

But there is no way to get metrics because we need to use worker class from AIOHTTP (`aiohttp.GunicornWebWorker`) and it does not use `access` method of the logger (https://github.com/benoitc/gunicorn/blob/master/gunicorn/instrument/statsd.py#L90). It's uses `info` (https://github.com/aio-libs/aiohttp/blob/master/aiohttp/web_log.py#L233) for access logs.

I'm very interested in that feature and I like to help with development. I see two ways of implementation:
1. Somehow refactor current code-base to use `access` method of the logger.
2. Provide optional instrumentation logic using the StatsD protocol in `aiohttp.GunicornWebWorker`, something like Gunicorn already have.

## Expected behaviour

Run application using Gunicorn and specify StatsD configuration parameters:
```
$ gunicorn -w 4 -b "0.0.0.0:4000" --worker-class=aiohttp.GunicornWebWorker --statsd-host="0.0.0.0:9125" --statsd-prefix=aiohttp app_aiohttp:get_application
```

Check StastD logs and see metrics with names `gunicorn.requests` and `gunicorn.request.duration`.

## Actual behaviour

Run application using Gunicorn and specify StatsD configuration parameters:
```
$ gunicorn -w 4 -b "0.0.0.0:4000" --worker-class=aiohttp.GunicornWebWorker --statsd-host="0.0.0.0:9125" --statsd-prefix=aiohttp app_aiohttp:get_application
```

Check StastD logs. You can see metric with name `gunicorn.workers`, but not with names `gunicorn.requests` and `gunicorn.request.duration`.

## Your environment

MacOS 10.14.4
aiohttp 3.5.4
gunicorn 19.9.0

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.