feat: per-connection observability added (#212)#214
Merged
hoytech merged 1 commit intohoytech:masterfrom Apr 22, 2026
Merged
Conversation
Contributor
Author
|
hi @hoytech , can you please review it once as this would be blocker for the second issue related to the back pressure work. |
Contributor
Author
|
Hi @hoytech , just a gentle follow-up on this PR. This is currently blocking the next issue related to back-pressure, so a review when you have time would really help. Happy to make any changes if needed. |
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.
Description
This PR adds per-connection observability for outbound payload still inside uWebSockets on the relay WebSocket server.
src/apps/relay/RelayWebsocket.cppConnection::StatswithpendingOutbound: application bytes passed toWebSocket::sendthat are not yet fully drained (still in uWS’s queue or an in-flight partial write).doSend, incrementspendingOutboundbypayload.size()immediately beforesend(), passes that size through the send completion callback’s user-data pointer (uintptr_tviavoid *), and decrements in the callback when uWS reports the message finished (success, immediate failure, or after queued drain).ws == nullptr, matching uWS’sonEndflush path: that runs afteronDisconnectionhas logged and deleted theConnection, so we must not dereferencegetUserData()there. The disconnect log therefore captures whateverpendingOutboundwas at teardown time; post-disconnect cancellation callbacks do not touch freed memory.Pending: …using the samerenderSizehelper.No change to when or what is sent; no new config; no back-pressure or connection termination (follow-up work).
Related Issue
Closes #212
Motivation and Context
Slow or stalled readers can leave a large amount of application payload buffered inside uWS. Today operators see aggregate UP bytes on disconnect but not how much was still queued at disconnect. This change makes that visible per connection so memory pressure and slow peers are easier to correlate, without claiming full TCP buffer accounting.
How Has This Been Tested?
Environment: Local build (e.g. WSL/Linux with existing strfry toolchain per README).
Commands run:
make -j4(or project-equivalent full relay build)./strfry relay, WebSocket client connect → REQ path that receives outbound frames → clean close; confirm disconnect log includesPending:(e.g.0bwhen the queue has drained before close).Automated tests: None added; there is no existing unit/integration target in this repo for
RelayWebsocket/ uWS intest/. (If you add one before opening the PR, update this section.)Screenshots (if appropriate): N/A
Types of changes
Checklist