janiussyafiq opened a new pull request, #13909: URL: https://github.com/apache/apisix/pull/13909
### Description #### Motivation On a route that serves WebSocket traffic, the `request` and `upstream` types of `apisix_http_latency` are observed in the log phase, which for an upgraded connection only runs when the session closes. Both values therefore equal the lifetime of the session (`$upstream_response_time` also stops only when the upstream connection closes), not a request/response round trip. A handful of long-lived sessions is enough to push the histogram's buckets and quantiles far beyond any real latency, so the metric stops being representative on those routes. #### What this PR does - Adds an opt-in boolean `exclude_websocket_latency` to the `prometheus` plugin metadata, next to `disabled_labels`, so it is hot-reloadable through the Admin API. - When it is set and the response status is `101 Switching Protocols`, the `request` and `upstream` observations are skipped for that request. - The `apisix` type is still recorded: the session lifetime is in both of its terms and cancels out, so it keeps measuring the gateway's own overhead. `apisix_http_status` and `apisix_bandwidth` are unchanged. - The trigger is the 101 response, not the route's `enable_websocket` flag or the client's `Upgrade` header, so a refused handshake on the same route is still measured as an ordinary request. - Defaults to off, so existing metric series do not change unless the operator opts in. Tests cover the default path, the opt-in path (only `request` and `upstream` are skipped, `apisix` and `http_status` still count), a non-upgraded request on the same route, and schema validation. English and Chinese docs are updated. #### Which issue(s) this PR fixes: Fixes #12661 ### Checklist - [x] I have explained the need for this PR and the problem it solves - [x] I have explained the changes or the new features added to this PR - [x] I have added tests corresponding to this change - [x] I have updated the documentation to reflect this change - [x] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first) -- 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]
