Skip to content

Commit 47a5cd8

Browse files
Add missing telemetry and extra logging (#391)
* Add missing telemetry and extra logging * fix lint * Add more log and telemetry * Add more logging * fix lint * add telemery for inline
1 parent 695d259 commit 47a5cd8

File tree

13 files changed

+68
-4
lines changed

13 files changed

+68
-4
lines changed

src/extension/common/application/debugSessionTelemetry.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,21 @@ class TelemetryTracker implements DebugAdapterTracker {
4141
this.sendTelemetry(EventName.DEBUG_SESSION_STOP);
4242
}
4343

44-
public onError?(_error: Error): void {
45-
this.sendTelemetry(EventName.DEBUG_SESSION_ERROR);
44+
public onError?(error: Error): void {
45+
this.sendTelemetry(EventName.DEBUG_SESSION_ERROR, error);
4646
}
4747

48-
private sendTelemetry(eventName: EventName): void {
48+
private sendTelemetry<P extends IEventNamePropertyMapping, E extends keyof P>(
49+
eventName: EventName,
50+
properties?: P[E],
51+
): void {
4952
if (eventName === EventName.DEBUG_SESSION_START) {
5053
this.timer.reset();
5154
}
5255
const telemetryProps = {
5356
trigger: this.trigger,
5457
console: this.console,
58+
...properties,
5559
};
5660
sendTelemetryEvent(eventName as keyof IEventNamePropertyMapping, this.timer.elapsedTime, telemetryProps);
5761
}

src/extension/debugger/adapter/factory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac
149149
}
150150

151151
private async showDeprecatedPythonMessage() {
152+
sendTelemetryEvent(EventName.DEBUGGER_PYTHON_37_DEPRECATED);
152153
const notificationPromptEnabled = this.persistentState.createGlobalPersistentState(
153154
debugStateKeys.doNotShowAgain,
154155
false,

src/extension/debugger/configuration/dynamicdebugConfigurationService.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { IDynamicDebugConfigurationService } from '../types';
1010
import { DebuggerTypeName } from '../../constants';
1111
import { replaceAll } from '../../common/stringUtils';
1212
import { getDjangoPaths, getFastApiPaths, getFlaskPaths } from './utils/configuration';
13+
import { sendTelemetryEvent } from '../../telemetry';
14+
import { EventName } from '../../telemetry/constants';
1315

1416
const workspaceFolderToken = '${workspaceFolder}';
1517

@@ -74,6 +76,8 @@ export class DynamicPythonDebugConfigurationService implements IDynamicDebugConf
7476
});
7577
}
7678

79+
sendTelemetryEvent(EventName.DEBUGGER_DYNAMIC_CONFIGURATION, undefined, { providers: providers });
80+
7781
return providers;
7882
}
7983
}

src/extension/debugger/configuration/launch.json/launchJsonReader.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ import * as fs from 'fs-extra';
66
import { parse } from 'jsonc-parser';
77
import { DebugConfiguration, Uri, WorkspaceFolder } from 'vscode';
88
import { getConfiguration, getWorkspaceFolder } from '../../../common/vscodeapi';
9+
import { traceLog } from '../../../common/log/logging';
910

1011
export async function getConfigurationsForWorkspace(workspace: WorkspaceFolder): Promise<DebugConfiguration[]> {
12+
traceLog('Getting configurations for workspace');
1113
const filename = path.join(workspace.uri.fsPath, '.vscode', 'launch.json');
1214
if (!(await fs.pathExists(filename))) {
1315
// Check launch config in the workspace file
1416
const codeWorkspaceConfig = getConfiguration('launch', workspace);
1517
if (!codeWorkspaceConfig.configurations || !Array.isArray(codeWorkspaceConfig.configurations)) {
1618
return [];
1719
}
20+
traceLog('Using configuration in workspace');
1821
return codeWorkspaceConfig.configurations;
1922
}
2023

@@ -26,7 +29,7 @@ export async function getConfigurationsForWorkspace(workspace: WorkspaceFolder):
2629
if (!parsed.version) {
2730
throw Error('Missing field in launch.json: version');
2831
}
29-
// We do not bother ensuring each item is a DebugConfiguration...
32+
traceLog('Using configuration in launch.json');
3033
return parsed.configurations;
3134
}
3235

src/extension/debugger/configuration/resolvers/attach.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import { getOSType, OSType } from '../../../common/platform';
88
import { AttachRequestArguments, DebugOptions, PathMapping } from '../../../types';
99
import { BaseConfigurationResolver } from './base';
1010
import { getConfiguration } from '../../../common/vscodeapi';
11+
import { traceLog } from '../../../common/log/logging';
1112

1213
export class AttachConfigurationResolver extends BaseConfigurationResolver<AttachRequestArguments> {
1314
public async resolveDebugConfigurationWithSubstitutedVariables(
1415
folder: WorkspaceFolder | undefined,
1516
debugConfiguration: AttachRequestArguments,
1617
_token?: CancellationToken,
1718
): Promise<AttachRequestArguments | undefined> {
19+
traceLog('Resolving attach configuration with substituted variables');
1820
const workspaceFolder = AttachConfigurationResolver.getWorkspaceFolder(folder);
1921

2022
await this.provideAttachDefaults(workspaceFolder, debugConfiguration as AttachRequestArguments);

src/extension/debugger/configuration/resolvers/base.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { resolveVariables } from '../utils/common';
1616
import { getProgram } from './helper';
1717
import { getSettingsPythonPath, getInterpreterDetails } from '../../../common/python';
1818
import { getOSType, OSType } from '../../../common/platform';
19+
import { traceLog } from '../../../common/log/logging';
1920

2021
export abstract class BaseConfigurationResolver<T extends DebugConfiguration>
2122
implements IDebugConfigurationResolver<T>
@@ -62,14 +63,17 @@ export abstract class BaseConfigurationResolver<T extends DebugConfiguration>
6263
const workspaceFolders = getWorkspaceFolders();
6364

6465
if (!Array.isArray(workspaceFolders) || workspaceFolders.length === 0) {
66+
traceLog('No workspace folder found');
6567
return program ? Uri.file(path.dirname(program)) : undefined;
6668
}
6769
if (workspaceFolders.length === 1) {
70+
traceLog('Using the only workspaceFolder found: ', workspaceFolders[0].uri.fsPath);
6871
return workspaceFolders[0].uri;
6972
}
7073
if (program) {
7174
const workspaceFolder = getVSCodeWorkspaceFolder(Uri.file(program));
7275
if (workspaceFolder) {
76+
traceLog('Using workspaceFolder found for the program: ', workspaceFolder.uri.fsPath);
7377
return workspaceFolder.uri;
7478
}
7579
}

src/extension/debugger/configuration/resolvers/launch.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { resolveVariables } from '../utils/common';
1212
import { BaseConfigurationResolver } from './base';
1313
import { getDebugEnvironmentVariables, getProgram } from './helper';
1414
import { getConfiguration } from '../../../common/vscodeapi';
15+
import { traceLog } from '../../../common/log/logging';
1516

1617
export class LaunchConfigurationResolver extends BaseConfigurationResolver<LaunchRequestArguments> {
1718
public async resolveDebugConfiguration(
@@ -51,6 +52,7 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver<Launc
5152
debugConfiguration: LaunchRequestArguments,
5253
_token?: CancellationToken,
5354
): Promise<LaunchRequestArguments | undefined> {
55+
traceLog('Resolving launch configuration with substituted variables');
5456
const workspaceFolder = LaunchConfigurationResolver.getWorkspaceFolder(folder);
5557
await this.provideLaunchDefaults(workspaceFolder, debugConfiguration);
5658

src/extension/debugger/hooks/childProcessAttachService.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { AttachRequestArguments } from '../../types';
1010
import { IChildProcessAttachService } from './types';
1111
import { getWorkspaceFolders, showErrorMessage } from '../../common/vscodeapi';
1212
import { noop } from '../../common/utils/misc';
13+
import { traceLog } from '../../common/log/logging';
1314

1415
/**
1516
* This class is responsible for attaching the debugger to any
@@ -27,6 +28,7 @@ export class ChildProcessAttachService implements IChildProcessAttachService {
2728
lifecycleManagedByParent: true,
2829
};
2930
const folder = this.getRelatedWorkspaceFolder(debugConfig);
31+
traceLog('Start debugger in the attach child proccess');
3032
const launched = await debug.startDebugging(folder, debugConfig, debugSessionOption);
3133
if (!launched) {
3234
showErrorMessage(l10n.t('Failed to launch debugger for child process {0}', debugConfig.subProcessId!)).then(

src/extension/debugger/hooks/debugpySocketsHandler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { DebuggerEvents } from './constants';
1010
import { DebuggerTypeName } from '../../constants';
1111
import { DebugPortAttributesProvider } from '../debugPort/portAttributesProvider';
1212
import { IDebugSessionEventHandlers } from './types';
13+
import { traceLog } from '../../common/log/logging';
1314

1415
/**
1516
* This class is responsible for register ports using by debugpy in the portProvider.
@@ -30,6 +31,7 @@ export class DebugpySocketsHandler implements IDebugSessionEventHandlers {
3031
}
3132

3233
if (event.event === DebuggerEvents.DebugpySockets) {
34+
traceLog("Received 'debugpySockets' event from debugpy.");
3335
let portSocket = event.body.sockets.find((socket: { [x: string]: any }) => {
3436
return socket['internal'] === false;
3537
});

src/extension/debugger/inlineValue/pythonInlineValueProvider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
InlineValueEvaluatableExpression,
1212
} from 'vscode';
1313
import { customRequest } from '../../common/vscodeapi';
14+
import { sendTelemetryEvent } from '../../telemetry';
15+
import { EventName } from '../../telemetry/constants';
1416

1517
export class PythonInlineValueProvider implements InlineValuesProvider {
1618
public async provideInlineValues(
@@ -100,6 +102,7 @@ export class PythonInlineValueProvider implements InlineValuesProvider {
100102
}
101103
}
102104
}
105+
sendTelemetryEvent(EventName.DEBUGGER_SHOW_PYTHON_INLINE_VALUES);
103106
return allValues;
104107
}
105108
}

0 commit comments

Comments
 (0)