errorTelemetry.ts ×9

Frontier kind: Code frontier

unlabeled · c_0b6fd691dd6b

8 tests · 17672 LOC · 63 files · introduces 0 tests · 83 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges83 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1747 ranges17672 lines · 63 files · Browse complete extent
All tests (intent)
8 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 83 introduced LOC across 9 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/telemetry/common/errorTelemetry.ts 83 introduced LOC · 9 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- errorTelemetry.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { binarySearch } from '../../../base/common/arrays.js';
7 > import { errorHandler, ErrorNoTelemetry, PendingMigrationError } from '../../../base/common/errors.js';
8 > import { ListenerLeakError } from '../../../base/common/event.js';
9 > import { DisposableStore, toDisposable } from '../../../base/common/lifecycle.js';
10 > import { safeStringify } from '../../../base/common/objects.js';
11 > import { FileOperationError } from '../../files/common/files.js';
12 > import { ITelemetryService } from './telemetry.js';
13 >
14 > export type ErrorEventFragment = {
15 > owner: 'lramos15, sbatten';
16 > comment: 'Whenever an error in VS Code is thrown.';
17 > callstack: { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth'; comment: 'The callstack of the error.' };
18 > msg?: { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth'; comment: 'The message of the error. Normally the first line int the callstack.' };
19 > file?: { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth'; comment: 'The file the error originated from.' };
20 > line?: { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth'; comment: 'The line the error originate on.' };
21 > column?: { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth'; comment: 'The column of the line which the error orginated on.' };
22 > uncaught_error_name?: { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth'; comment: 'If the error is uncaught what is the error type' };
23 > uncaught_error_msg?: { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth'; comment: 'If the error is uncaught this is just msg but for uncaught errors.' };
24 > count?: { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth'; comment: 'How many times this error has been thrown' };
25 > };
26 >
27 > type ListenerLeakDiagEvent = {
28 > kind?: string;
29 > listenerCount?: number;
30 > };
31 >
32 > type ListenerLeakDiagFragment = {
33 > kind?: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Whether the leak is dominated by a single subscriber or popular among many.' };
34 > listenerCount?: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Number of listeners on the emitter when the leak was detected.' };
35 > };
36 >
37 > type UnhandledErrorEvent = ErrorEvent & ListenerLeakDiagEvent;
38 > type UnhandledErrorClassification = ErrorEventFragment & ListenerLeakDiagFragment;
39 >
40 > export interface ErrorEvent {
41 > callstack: string;
42 > msg?: string;
43 > file?: string;
44 > line?: number;
45 > column?: number;
46 > uncaught_error_name?: string;
47 > uncaught_error_msg?: string;
48 > count?: number;
49 > }
50 >
51 > export namespace ErrorEvent {
52 > export function compare(a: ErrorEvent, b: ErrorEvent) {
53 if (a.callstack < b.callstack) {
54 return -1;
58 return 0;
59 }
61 >
62 > /**
63 > * Extracts a callstack and message from an error object for telemetry.
64 > * Handles the `Array.isArray(err.stack)` workaround from workerServer.ts
65 > * and falls back to {@link safeStringify} when no message is available.
66 > */
67 > export function packErrorForTelemetry(err: any): { callstack: string | undefined; msg: string } {
68 if (!err || typeof err !== 'object') {
69 return { callstack: undefined, msg: safeStringify(err) };
73 return { callstack, msg };
74 }
76 > export default abstract class BaseErrorTelemetry {
77 >
78 > public static ERROR_FLUSH_TIMEOUT: number = 5 * 1000;
79 >
80 > private _telemetryService: ITelemetryService;
81 > private _flushDelay: number;
82 > private _flushHandle: Timeout | undefined = undefined;
83 > private _buffer: ErrorEvent[] = [];
84 > protected readonly _disposables = new DisposableStore();
85 >
86 > constructor(telemetryService: ITelemetryService, flushDelay = BaseErrorTelemetry.ERROR_FLUSH_TIMEOUT) {
87 this._telemetryService = telemetryService;
88 this._flushDelay = flushDelay;
95 this.installErrorListeners();
96 }
98 > dispose() {
99 clearTimeout(this._flushHandle);
100 this._flushBuffer();
101 this._disposables.dispose();
102 }
104 > protected installErrorListeners(): void {
105 // to override
106 }
108 > private _onErrorEvent(err: any): void {
109
110 if (!err || err.code) {
145 this._enqueue(errorEvent);
146 }
148 > protected _enqueue(e: ErrorEvent): void {
149
150 const idx = binarySearch(this._buffer, e, ErrorEvent.compare);
166 }
167 }
169 > private _flushBuffer(): void {
170 for (const error of this._buffer) {
171 this._telemetryService.publicLogError2<UnhandledErrorEvent, UnhandledErrorClassification>('UnhandledError', error as UnhandledErrorEvent);