Skip to content

Commit

Permalink
add telemetry to give insight for experiment (#212401)
Browse files Browse the repository at this point in the history
* add telemetry to give insight for experiment

* conventional event name, skip for cancellation
  • Loading branch information
amunger authored May 10, 2024
1 parent dc7a2cd commit c5e287e
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { assertType } from 'vs/base/common/types';
import { URI } from 'vs/base/common/uri';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWriteFileOptions, IFileStatWithMetadata } from 'vs/platform/files/common/files';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IRevertOptions, ISaveOptions, IUntypedEditorInput } from 'vs/workbench/common/editor';
import { EditorModel } from 'vs/workbench/common/editor/editorModel';
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
Expand Down Expand Up @@ -241,8 +242,30 @@ export class NotebookFileWorkingCopyModel extends Disposable implements IStoredF
throw new CancellationError();
}

const stat = await serializer.save(this._notebookModel.uri, this._notebookModel.versionId, options, token);
return stat;
try {
const stat = await serializer.save(this._notebookModel.uri, this._notebookModel.versionId, options, token);
return stat;
} catch (error) {
if (!token.isCancellationRequested) {
type notebookSaveErrorData = {
isRemote: boolean;
versionMismatch: boolean;
};
type notebookSaveErrorClassification = {
owner: 'amunger';
comment: 'Detect if we are having issues saving a notebook on the Extension Host';
isRemote: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Whether the save is happening on a remote file system' };
versionMismatch: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'If the error was because of a version mismatch' };
};
const telemetry = {} as ITelemetryService;
telemetry.publicLogError2<notebookSaveErrorData, notebookSaveErrorClassification>('notebook/SaveError', {
isRemote: this._notebookModel.uri.scheme === Schemas.vscodeRemote,
versionMismatch: error instanceof Error && error.message === 'Document version mismatch'
});
}

throw error;
}
};
}

Expand Down

0 comments on commit c5e287e

Please sign in to comment.