add telemetry to give insight for experiment (#212401)

* add telemetry to give insight for experiment

* conventional event name, skip for cancellation
This commit is contained in:
Aaron Munger 2024-05-10 08:59:31 -07:00 committed by GitHub
parent dc7a2cd4d7
commit c5e287efea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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';
@ -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;
}
};
}