Skip to content

Commit 29aa551

Browse files
authored
Telemetry on stateful marker and compaction (#4558)
1 parent 450f2e7 commit 29aa551

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/platform/networking/node/chatWebSocketManager.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,8 @@ class ChatWebSocketConnection extends Disposable implements IChatWebSocketConnec
446446
}
447447

448448
const statefulMarkerMatched = this._statefulMarker === body.previous_response_id;
449+
const previousResponseIdUnset = body.previous_response_id === undefined;
450+
const hasCompactionData = body.input?.some(item => item?.type === 'compaction') ?? false;
449451
const statefulMarkerPrefix = this._statefulMarker?.slice(0, 5).concat('...') ?? '<none>';
450452
const previousResponsePrefix = body.previous_response_id?.slice(0, 5).concat('...') ?? '<none>';
451453
if (statefulMarkerMatched) {
@@ -477,6 +479,8 @@ class ChatWebSocketConnection extends Disposable implements IChatWebSocketConnec
477479
gitHubRequestId: this._gitHubRequestId,
478480
requestOutcome: outcome,
479481
statefulMarkerMatched,
482+
previousResponseIdUnset,
483+
hasCompactionData,
480484
connectionDurationMs,
481485
requestDurationMs,
482486
totalSentMessageCount: this._totalSentMessageCount,
@@ -523,6 +527,8 @@ class ChatWebSocketConnection extends Disposable implements IChatWebSocketConnec
523527
requestId: this._requestId,
524528
gitHubRequestId: this._gitHubRequestId,
525529
statefulMarkerMatched,
530+
previousResponseIdUnset,
531+
hasCompactionData,
526532
connectionDurationMs,
527533
totalSentMessageCount: this._totalSentMessageCount,
528534
totalReceivedMessageCount: this._totalReceivedMessageCount,

src/platform/networking/node/chatWebSocketTelemetry.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ export interface IChatWebSocketCloseDuringSetupTelemetryProperties extends IChat
5454

5555
export interface IChatWebSocketRequestSentTelemetryProperties extends IChatWebSocketBaseTelemetryProperties {
5656
statefulMarkerMatched: boolean;
57+
previousResponseIdUnset: boolean;
58+
hasCompactionData: boolean;
5759
connectionDurationMs: number;
5860
totalSentMessageCount: number;
5961
totalReceivedMessageCount: number;
@@ -77,6 +79,8 @@ export type ChatWebSocketRequestOutcome = 'completed' | 'server_error' | 'cancel
7779
export interface IChatWebSocketRequestOutcomeTelemetryProperties extends IChatWebSocketBaseTelemetryProperties {
7880
requestOutcome: ChatWebSocketRequestOutcome;
7981
statefulMarkerMatched: boolean;
82+
previousResponseIdUnset: boolean;
83+
hasCompactionData: boolean;
8084
connectionDurationMs: number;
8185
requestDurationMs: number;
8286
totalSentMessageCount: number;
@@ -273,6 +277,8 @@ export class ChatWebSocketTelemetrySender {
273277
"requestId": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Id of the current turn request" },
274278
"gitHubRequestId": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "GitHub request id if available" },
275279
"statefulMarkerMatched": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Whether the connection stateful marker matched the previous_response_id sent in the request", "isMeasurement": true },
280+
"previousResponseIdUnset": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Whether previous_response_id was undefined in the request", "isMeasurement": true },
281+
"hasCompactionData": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Whether the request input contains compaction data", "isMeasurement": true },
276282
"totalSentMessageCount": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Number of messages sent over this connection", "isMeasurement": true },
277283
"totalReceivedMessageCount": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Number of messages received over this connection", "isMeasurement": true },
278284
"sentMessageCharacters": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Character count of this sent message payload", "isMeasurement": true },
@@ -288,6 +294,8 @@ export class ChatWebSocketTelemetrySender {
288294
gitHubRequestId: properties.gitHubRequestId,
289295
}, {
290296
statefulMarkerMatched: properties.statefulMarkerMatched ? 1 : 0,
297+
previousResponseIdUnset: properties.previousResponseIdUnset ? 1 : 0,
298+
hasCompactionData: properties.hasCompactionData ? 1 : 0,
291299
totalSentMessageCount: properties.totalSentMessageCount,
292300
totalReceivedMessageCount: properties.totalReceivedMessageCount,
293301
sentMessageCharacters: properties.sentMessageCharacters,
@@ -348,6 +356,8 @@ export class ChatWebSocketTelemetrySender {
348356
"gitHubRequestId": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "GitHub request id if available" },
349357
"requestOutcome": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Terminal outcome of the websocket request" },
350358
"statefulMarkerMatched": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Whether the connection stateful marker matched the previous_response_id sent in the request", "isMeasurement": true },
359+
"previousResponseIdUnset": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Whether previous_response_id was undefined in the request", "isMeasurement": true },
360+
"hasCompactionData": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Whether the request input contains compaction data", "isMeasurement": true },
351361
"totalSentMessageCount": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Number of messages sent over this connection", "isMeasurement": true },
352362
"totalReceivedMessageCount": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Number of messages received over this connection", "isMeasurement": true },
353363
"totalSentCharacters": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Total characters sent over this connection", "isMeasurement": true },
@@ -375,6 +385,8 @@ export class ChatWebSocketTelemetrySender {
375385
serverErrorCode: properties.serverErrorCode,
376386
}, {
377387
statefulMarkerMatched: properties.statefulMarkerMatched ? 1 : 0,
388+
previousResponseIdUnset: properties.previousResponseIdUnset ? 1 : 0,
389+
hasCompactionData: properties.hasCompactionData ? 1 : 0,
378390
totalSentMessageCount: properties.totalSentMessageCount,
379391
totalReceivedMessageCount: properties.totalReceivedMessageCount,
380392
totalSentCharacters: properties.totalSentCharacters,

0 commit comments

Comments
 (0)