wy471x opened a new pull request, #7056:
URL: https://github.com/apache/shenyu/pull/7056
Fixes #6671
### Motivation
`shenyu_request_type_total` is labelled with the raw request path, so every
distinct
path (`/api/user/123`, `/api/order/456`, ...) creates a new `Counter.Child`
inside the
Prometheus client's internal children map, which is never evicted. The outer
counter/gauge/histogram maps are bounded by metric name, but that per-series
map is
not: heap usage grows with the number of distinct request paths, which is
unbounded
on a public-facing gateway with path parameters, and it also inflates the
`/metrics`
payload.
### Modification
- `MetricsPlugin`: increment `shenyu_request_type_total` with only `rpcType`
(a bounded
dimension) instead of `{rawPath, rpcType}`.
- `MetricsReporter`: register the counter with label names `{"type"}`.
- Added `MetricsPluginTest#testRequestTypeTotalIsNotLabelledByRawPath`, a
regression
test that asserts two different request paths produce the same label
vector.
### Result
The metric no longer carries a per-path series, so its cardinality is
bounded by the
number of rpc types instead of by the number of distinct request paths.
Note for reviewers: this changes the exposed label set of
`shenyu_request_type_total`
from `{path,type}` to `{type}`. It is an intentional, breaking change to the
metric
shape, since per-path granularity cannot be kept without the unbounded
cardinality.
### Verification
`./mvnw -pl shenyu-plugin/shenyu-plugin-metrics test` — 15 tests, all passing
(checkstyle and jacoco included).
Make sure that:
- [x] You have read the [contribution
guidelines](https://shenyu.apache.org/community/contributor-guide).
- [x] You submit test cases (unit or integration tests) that back your
changes.
- [ ] Your local test passed `./mvnw clean install
-Dmaven.javadoc.skip=true`. (I ran the
focused module build, `./mvnw -pl shenyu-plugin/shenyu-plugin-metrics
test`, instead.)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]