Skip to content

Commit 73f7610

Browse files
jriekenCopilot
andauthored
make inline.request also include tools telemetry (#2209)
* make `inline.request` also include tools telemetry fixes microsoft/vscode-internalbacklog#6349 * Update src/extension/prompt/node/chatParticipantTelemetry.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent b1c67ca commit 73f7610

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/extension/prompt/node/chatParticipantTelemetry.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ type RequestTelemetryProperties = {
133133
languageId: string | undefined;
134134
model: string;
135135
apiType: string | undefined;
136+
toolCounts: string;
136137
};
137138

138139
type RequestPanelTelemetryProperties = RequestTelemetryProperties & {
139140
responseId: string;
140141
codeBlocks: string;
141142
isParticipantDetected: string;
142-
toolCounts: string;
143143
};
144144

145145
type RequestTelemetryMeasurements = {
@@ -149,6 +149,8 @@ type RequestTelemetryMeasurements = {
149149
timeToComplete: number;
150150
responseTokenCount: number;
151151
messageTokenCount: number;
152+
numToolCalls: number;
153+
availableToolCount: number;
152154
};
153155

154156
type RequestPanelTelemetryMeasurements = RequestTelemetryMeasurements & {
@@ -158,8 +160,6 @@ type RequestPanelTelemetryMeasurements = RequestTelemetryMeasurements & {
158160
links: number;
159161
maybeOffTopic: number;
160162
userPromptCount: number;
161-
numToolCalls: number;
162-
availableToolCount: number;
163163
summarizationEnabled: number;
164164
};
165165

@@ -797,7 +797,12 @@ export class InlineChatTelemetry extends ChatTelemetry<IDocumentContext> {
797797
} satisfies RequestInternalInlineTelemetryMeasurements);
798798
}
799799

800-
protected override async _sendResponseTelemetryEvent(responseType: ChatFetchResponseType, response: string, interactionOutcome: InteractionOutcome): Promise<void> {
800+
protected override async _sendResponseTelemetryEvent(responseType: ChatFetchResponseType, response: string, interactionOutcome: InteractionOutcome, toolCalls: IToolCall[] = []): Promise<void> {
801+
802+
const toolCounts = toolCalls.reduce((acc, call) => {
803+
acc[call.name] = (acc[call.name] || 0) + 1;
804+
return acc;
805+
}, {} as Record<string, number>);
801806

802807

803808
/* __GDPR__
@@ -841,7 +846,10 @@ export class InlineChatTelemetry extends ChatTelemetry<IDocumentContext> {
841846
"codeGenInstructionsLength": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "comment": "The length of the code generation instructions that were added to request." },
842847
"codeGenInstructionsFilteredCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "comment": "How many code generation instructions were filtered." },
843848
"codeGenInstructionFileCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "comment": "How many code generation instruction files were read." },
844-
"codeGenInstructionSettingsCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "comment": "How many code generation instructions originated from settings." }
849+
"codeGenInstructionSettingsCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "comment": "How many code generation instructions originated from settings." },
850+
"toolCounts": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": false, "comment": "The number of times each tool was used" },
851+
"numToolCalls": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "comment": "The total number of tool calls" },
852+
"availableToolCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "comment": "How number of tools that were available." }
845853
}
846854
*/
847855
this._telemetryService.sendMSFTTelemetryEvent('inline.request', {
@@ -859,6 +867,7 @@ export class InlineChatTelemetry extends ChatTelemetry<IDocumentContext> {
859867
diagnosticCodes: this._diagnosticsTelemetryData.fileDiagnosticsTelemetry.diagnosticCodes,
860868
selectionDiagnosticCodes: this._diagnosticsTelemetryData.selectionDiagnosticsTelemetry.diagnosticCodes,
861869
outcomeAnnotations: interactionOutcome.annotations?.map(a => a.label).join(','),
870+
toolCounts: JSON.stringify(toolCounts),
862871
} satisfies RequestInlineTelemetryProperties, {
863872
firstTurn: this._firstTurn ? 1 : 0,
864873
isNotebook: this._isNotebookDocument,
@@ -881,6 +890,8 @@ export class InlineChatTelemetry extends ChatTelemetry<IDocumentContext> {
881890
timeToFirstToken: this._firstTokenTime ? this._firstTokenTime - this._startTime : -1,
882891
timeToComplete: Date.now() - this._startTime,
883892
...getCustomInstructionTelemetry(this._references),
893+
numToolCalls: toolCalls.length,
894+
availableToolCount: this._availableToolCount,
884895
} satisfies RequestInlineTelemetryMeasurements);
885896
}
886897

0 commit comments

Comments
 (0)