Add new default metric: inflight gauge#481
Open
john-wd wants to merge 2 commits intodjango-commons:masterfrom
Open
Add new default metric: inflight gauge#481john-wd wants to merge 2 commits intodjango-commons:masterfrom
john-wd wants to merge 2 commits intodjango-commons:masterfrom
Conversation
django_prometheus/middleware.py
Outdated
| name = self._get_view_name(request) | ||
| status = str(response.status_code) | ||
| self.label_metric(self.metrics.inflight_requests, request).dec() | ||
| self.label_metric(self.metrics.requests_total_by_view, request, view=name).inc() |
There was a problem hiding this comment.
I don't think we need this additional metric. As it can be easily constructed from the responses_by_status_view_method metric by sum(...) by (view). Is there a reason this doesn't work for your use case?
Author
There was a problem hiding this comment.
Yeah, I think you are right, this should suffice for this usecase. Thanks.
Author
There was a problem hiding this comment.
Remove this dupe from my latest commit, kept the inflights one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
From my experience working with web applications, we usually want to track an additional quantity. Why?
The reason is simple:
This PR adds this metric to the default
Aftermiddleware, so if will be available for everyone for free.I haven't added tests yet, first I want to run by the maintainers to see if it looks good enough to proceed, then I can add tests accordingly.