Skip to content

Commit 57f489b

Browse files
authored
Merge pull request microsoft#165599 from laurentlb/telemetry
Telemetry: log command execution time
2 parents afac952 + 36b82a9 commit 57f489b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/vs/workbench/api/common/extHostCommands.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ export class ExtHostCommands implements ExtHostCommandsShape {
224224
if (!command) {
225225
throw new Error('Unknown command');
226226
}
227-
this._reportTelemetry(command, id);
228227
const { callback, thisArg, description } = command;
229228
if (description) {
230229
for (let i = 0; i < description.args.length; i++) {
@@ -236,6 +235,7 @@ export class ExtHostCommands implements ExtHostCommandsShape {
236235
}
237236
}
238237

238+
const start = Date.now();
239239
try {
240240
return await callback.apply(thisArg, args);
241241
} catch (err) {
@@ -261,25 +261,31 @@ export class ExtHostCommands implements ExtHostCommandsShape {
261261
}
262262
};
263263
}
264+
finally {
265+
this._reportTelemetry(command, id, Date.now() - start);
266+
}
264267
}
265268

266-
private _reportTelemetry(command: CommandHandler, id: string) {
269+
private _reportTelemetry(command: CommandHandler, id: string, duration: number) {
267270
if (!command.extension || command.extension.isBuiltin) {
268271
return;
269272
}
270273
type ExtensionActionTelemetry = {
271274
extensionId: string;
272275
id: string;
276+
duration: number;
273277
};
274278
type ExtensionActionTelemetryMeta = {
275279
extensionId: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The id of the extension handling the command, informing which extensions provide most-used functionality.' };
276280
id: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The id of the command, to understand which specific extension features are most popular.' };
281+
duration: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'The duration of the command execution, to detect performance issues' };
277282
owner: 'digitarald';
278283
comment: 'Used to gain insight on the most popular commands used from extensions';
279284
};
280285
this.#telemetry.$publicLog2<ExtensionActionTelemetry, ExtensionActionTelemetryMeta>('Extension:ActionExecuted', {
281286
extensionId: command.extension.identifier.value,
282287
id: id,
288+
duration: duration,
283289
});
284290
}
285291

0 commit comments

Comments
 (0)