fix(metrics): fix metrics
This commit is contained in:
@ -123,6 +123,11 @@ export class HttpProxyBridge {
|
||||
|
||||
// Send initial chunk if present
|
||||
if (initialChunk) {
|
||||
// Count the initial chunk bytes
|
||||
record.bytesReceived += initialChunk.length;
|
||||
if (this.smartProxy.metricsCollector) {
|
||||
this.smartProxy.metricsCollector.recordBytes(record.id, initialChunk.length, 0);
|
||||
}
|
||||
proxySocket.write(initialChunk);
|
||||
}
|
||||
|
||||
@ -132,20 +137,18 @@ export class HttpProxyBridge {
|
||||
|
||||
setupBidirectionalForwarding(underlyingSocket, proxySocket, {
|
||||
onClientData: (chunk) => {
|
||||
// Update stats if needed
|
||||
// Update stats - this is the ONLY place bytes are counted for HttpProxy connections
|
||||
if (record) {
|
||||
record.bytesReceived += chunk.length;
|
||||
// Also record in metrics collector for throughput tracking
|
||||
if (this.smartProxy.metricsCollector) {
|
||||
this.smartProxy.metricsCollector.recordBytes(record.id, chunk.length, 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
onServerData: (chunk) => {
|
||||
// Update stats if needed
|
||||
// Update stats - this is the ONLY place bytes are counted for HttpProxy connections
|
||||
if (record) {
|
||||
record.bytesSent += chunk.length;
|
||||
// Also record in metrics collector for throughput tracking
|
||||
if (this.smartProxy.metricsCollector) {
|
||||
this.smartProxy.metricsCollector.recordBytes(record.id, 0, chunk.length);
|
||||
}
|
||||
|
Reference in New Issue
Block a user