Skip to content

Commit

Permalink
telemetry for duration of code actions on save (#225452)
Browse files Browse the repository at this point in the history
* add telemetry on code actions on save

* cleanup
  • Loading branch information
justschen authored Aug 13, 2024
1 parent 92183a6 commit 922413f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/vs/workbench/contrib/codeEditor/browser/saveParticipants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
import { HierarchicalKind } from 'vs/base/common/hierarchicalKind';
import { Disposable } from 'vs/base/common/lifecycle';
import { StopWatch } from 'vs/base/common/stopwatch';
import * as strings from 'vs/base/common/strings';
import { IActiveCodeEditor, isCodeEditor } from 'vs/editor/browser/editorBrowser';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
Expand All @@ -27,6 +28,7 @@ import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IProgress, IProgressStep, Progress } from 'vs/platform/progress/common/progress';
import { Registry } from 'vs/platform/registry/common/platform';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchContributionsExtensions } from 'vs/workbench/common/contributions';
import { SaveReason } from 'vs/workbench/common/editor';
import { getModifiedRanges } from 'vs/workbench/contrib/format/browser/formatModified';
Expand Down Expand Up @@ -278,6 +280,7 @@ class CodeActionOnSaveParticipant extends Disposable implements ITextFileSavePar
@IHostService private readonly hostService: IHostService,
@IEditorService private readonly editorService: IEditorService,
@ICodeEditorService private readonly codeEditorService: ICodeEditorService,
@ITelemetryService private readonly telemetryService: ITelemetryService
) {
super();

Expand Down Expand Up @@ -408,7 +411,27 @@ class CodeActionOnSaveParticipant extends Disposable implements ITextFileSavePar
};

for (const codeActionKind of codeActionsOnSave) {
const sw = new StopWatch();

const actionsToRun = await this.getActionsToRun(model, codeActionKind, excludes, getActionProgress, token);

// Telemetry for duration of each code action on save.
type CodeActionOnSave = {
codeAction: string;
duration: number;
};
type CodeActionOnSaveClassification = {
owner: 'justschen';
comment: 'Information about the code action that was accepted on save.';
codeAction: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Kind of the code action setting that is run.' };
duration: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Duration it took for TS to return the action to run for each kind. ' };
};

this.telemetryService.publicLog2<CodeActionOnSave, CodeActionOnSaveClassification>('codeAction.appliedOnSave', {
codeAction: codeActionKind.value,
duration: sw.elapsed()
});

if (token.isCancellationRequested) {
actionsToRun.dispose();
return;
Expand Down

0 comments on commit 922413f

Please sign in to comment.