admin: add invert_filter query param to /stats#46073
Conversation
Signed-off-by: aakugan <aakashganapathy2@gmail.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces an invert_filter query parameter to the /stats and /stats/prometheus admin endpoints, allowing users to exclude stats matching the specified regular expression. The changes include parameter parsing, logic to invert the regex matching results, updated documentation, and comprehensive unit tests. The review feedback suggests two improvements: using the more idiomatic query_.has() method to check for the presence of the query parameter, and defensively handling null filters within shouldShowMetricName to simplify callers and prevent potential null pointer dereferences.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: aakugan <164153358+aakugan@users.noreply.github.com> Signed-off-by: aakugan <aakashganapathy2@gmail.com>
|
@agrawroh could you TAL? |
Commit Message
admin: add invert_filter query param to /stats
Additional Description
Adds an
invert_filterquery parameter to the admin/statsendpoint (text, json, and prometheus formats). When present alongsidefilter, the RE2 regex is inverted: stats whose names match the filter are excluded, and non-matching stats are returned.Example:
/stats?filter=server&invert_filterreturns all stats except those matchingserver.invert_filterwithoutfilterreturns HTTP 400.Needed because the re2 engine is not great at handling inversions like these.
Testing:
stats_params_test: parse validation (invert_filterrequiresfilter),shouldShowMetricpositive/negative casesstats_handler_test: invert filter for text, json, and prometheus outputstats_request_test: prometheus stat-map filtering with inverted filteradmin_test: admin integration coverageRisk Level
Low