Add WebSocket client metrics#4118
Conversation
d16260f to
49cdeda
Compare
|
@LivingLikeKrillin On most classes you have |
Add WEBSOCKET_CLIENT_PREFIX, HANDSHAKE_TIME, and CONNECTION_DURATION constants, meter/observation documentation enums, and recorder interfaces with Micrometer-based implementation. Related to reactor#3820 Signed-off-by: LivingLikeKrillin <143606756+LivingLikeKrillin@users.noreply.github.com>
Replace the HTTP metrics handler with a WebSocket-aware handler on upgrade. Connection duration is recorded when the handler is removed from the pipeline. Control frames (Close, Ping, Pong) are excluded from data metrics. Related to reactor#3820 Signed-off-by: LivingLikeKrillin <143606756+LivingLikeKrillin@users.noreply.github.com>
Test handshake time, data received/sent, connection duration, handshake failure, and protocol combinations (HTTP/1.1 and H2). Related to reactor#3820 Signed-off-by: LivingLikeKrillin <143606756+LivingLikeKrillin@users.noreply.github.com>
49cdeda to
dcbecaa
Compare
Signed-off-by: LivingLikeKrillin <143606756+LivingLikeKrillin@users.noreply.github.com>
7161609 to
10db602
Compare
violetagg
left a comment
There was a problem hiding this comment.
I have proposal for moving handshake timer to the abstract class so that it is available for all handlers. What do you think?
|
Please also ensure you have |
- Compute path and contextView eagerly in swapMetricsHandler() instead of lazy initialization via initMetrics() - Change extractProcessedDataFromBuffer parameter type to WebSocketFrame - Use GET for HTTP/1.1 and CONNECT for HTTP/2 via wsHttpMethod() - Restore missing @author raccoonback in WebsocketClientOperations Signed-off-by: LivingLikeKrillin <143606756+LivingLikeKrillin@users.noreply.github.com>
- Remove @nullable from path and contextView fields and parameters, since they are eagerly initialized in swapMetricsHandler() - Remove dead code: null guards, ternary fallbacks, and else branches in ContextAwareWebSocketClientMetricsHandler that are unreachable after the @nullable removal - Remove unused copy constructors from all handler classes - Move resolvePath() from AbstractWebSocketClientMetricsHandler to WebsocketClientOperations where it is actually called - Remove unused URI parameter from swapMetricsHandler() - Remove unused status parameter from recordHandshakeFailure() and hardcode "ERROR" since no other value is used - Rename metric namespace from reactor.netty.http.client.websocket to reactor.netty.websocket.client Signed-off-by: LivingLikeKrillin <143606756+LivingLikeKrillin@users.noreply.github.com>
Accumulate data across fragmented WebSocket frames and record metrics only when isFinalFragment() is true, instead of recording per individual frame. - Set dataSentTime/dataReceivedTime only on the first fragment - Accumulate dataSent/dataReceived across continuation frames - Record and reset counters on final fragment - Use synchronous recording in write() since reactor-netty's SendManyInner does not support ChannelPromise.addListener() Signed-off-by: LivingLikeKrillin <143606756+LivingLikeKrillin@users.noreply.github.com>
- testWebSocketFragmentedDataSentMetrics: verify that sending 3 fragments records DATA_SENT once with accumulated total - testWebSocketFragmentedDataReceivedMetrics: verify that receiving 2 fragments records DATA_RECEIVED once with accumulated total - Add /ws-fragment server route that sends fragmented frames Signed-off-by: LivingLikeKrillin <143606756+LivingLikeKrillin@users.noreply.github.com>
10db602 to
06045d4
Compare
- Move handshake timer (handshakeStartTime, startHandshake, recordHandshakeComplete, recordHandshakeFailure) from MicrometerWebSocketClientMetricsHandler to AbstractWebSocketClientMetricsHandler so all handler variants can record handshake time - Override handshake methods in ContextAwareWebSocketClientMetricsHandler to pass contextView to the recorder - Record write metrics via promise.addListener() to ensure metrics are captured only after successful write; use promise.unvoid() to handle VoidChannelPromise - Remove unused parameters: ctx from recordConnectionClosed and recordException, channel from recordRead - Add DefaultWebSocketClientMetricsRecorder to wrap plain HttpClientMetricsRecorder for custom recorder support - Restructure swapMetricsHandler with recorder type checking and wrapper pattern for non-WebSocket-aware recorders - Change micrometerWsHandler type from MicrometerWebSocketClientMetricsHandler to AbstractWebSocketClientMetricsHandler - Make path and contextView fields final in AbstractWebSocketClientMetricsHandler - Fix FQN usage: import Channel in ContextAwareWebSocketClientMetricsHandler Signed-off-by: LivingLikeKrillin <143606756+LivingLikeKrillin@users.noreply.github.com>
06045d4 to
7dfb184
Compare
|
Hi @violetagg, round 3 changes are pushed. Here's what was addressed:
The DCO check is green. Could you take another look when you have a moment? |
Co-authored-by: Violeta Georgieva <696661+violetagg@users.noreply.github.com> Signed-off-by: Violeta Georgieva <696661+violetagg@users.noreply.github.com>
Co-authored-by: Violeta Georgieva <696661+violetagg@users.noreply.github.com> Signed-off-by: Violeta Georgieva <696661+violetagg@users.noreply.github.com>
Signed-off-by: Violeta Georgieva <696661+violetagg@users.noreply.github.com>
Register the new ChannelHandler implementations introduced by the WebSocket client metrics feature in the GraalVM native-image reflect-config so that NativeConfigTest passes: - AbstractWebSocketClientMetricsHandler - ContextAwareWebSocketClientMetricsHandler - MicrometerWebSocketClientMetricsHandler - WebSocketClientMetricsHandler Signed-off-by: LivingLikeKrillin <143606756+LivingLikeKrillin@users.noreply.github.com>
|
Thanks for picking up the copyright and unused-import cleanup directly. The remaining CI failure was
Verified locally by running the same commands CI does:
Ready for another CI run. |
Summary
Add metrics support for WebSocket clients, including handshake time,
data received/sent, connection duration, and error counting.
with Micrometer-based implementation
upgrade and track connection duration via handler lifecycle
Test plan
Related to #3820