Repository navigation
feat: add byte tracking to ssh and pty connections - #30389
Conversation
bb60325 to
1773a6b
Compare
8dd0b88 to
83fbb53
Compare
| Reason: "server shut down", | ||
| RxBytes: conn.RxBytes(), | ||
| TxBytes: conn.TxBytes(), | ||
| }) |
There was a problem hiding this comment.
Could we wait for the connection's I/O to finish before reporting the final counts? This shutdown path reads the counters before closing the connection, so a read or write that's still running can add bytes afterward. The handler sends another disconnect report, but if the first one has already been flushed, the SQL upsert keeps its earlier counts. Reporting once after I/O finishes would avoid that timing-dependent undercount.
There was a problem hiding this comment.
Good question, this disconnect report here actually needs some fixing I think because once we hit the hard context, I think the agent is not going to be able to send a report anyway (trying to make rpc calls at this point fails with "context canceled" from what I saw when trying to test this a while back).
Even if that was not the case, since this is a hard cancellation I think it is no longer correct to wait for anything, we have to wrap up immediately what we can and exit.
In practice, the conn should have already been closed with the graceful shutdown and hit the other disconnection report, which I think should always have the correct counts since it runs after the connection closes.
ff2fa44 to
7a4d168
Compare
Also combine zero and null tests. They do pretty much the exact same thing, just set a value then check that `Valid` is still the same thing.
7a4d168 to
24ae697
Compare
Part of https://linear.app/codercom/issue/CLIENT-671/agent-additional-connection-log-debug-logging
For now, the bytes are recorded but not currently exposed on the API.