Skip to content

feat: stat_middleware #382

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yudytskiy
Copy link

Prometheus is good, but it uses file operations on each middleware hook; that might become a bottleneck.

Suggested middleware uses similar metrics, but it keeps statistics in memory and may be queried by the simple task when needed.

As soon as a middleware instance starts within a worker process, requesting stats requires getting stats from each worker middleware instance.

I suggest starting an additional worker task inside middleware for a special pub-sub stat broker, so kiqing its task leads to execution on each main worker process, gathering all results together.

This pull request is just an idea implementation and includes:

  • metrics classes
  • middleware using metrics
  • test for metrics
  • demo example stats script

I had to bump up the required mypy and black minimal versions to support modern generic syntax.

So I just share the idea of request-oriented statistics gathering via pub-sup broker.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant