Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/2732.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disable activation of conda environments in PowerShell.
2 changes: 1 addition & 1 deletion news/2 Fixes/2827.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Disable activation of conda environments in PowerShell.
Add logging along with some some improvements to the load times of the extension.
5 changes: 2 additions & 3 deletions src/client/activation/activationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import {
} from '../common/types';
import { OSDistro, OSType } from '../common/utils/platform';
import { IServiceContainer } from '../ioc/types';
import { sendTelemetryEvent } from '../telemetry';
import { PYTHON_LANGUAGE_SERVER_PLATFORM_NOT_SUPPORTED } from '../telemetry/constants';
import { getTelemetryReporter } from '../telemetry/telemetry';
import {
ExtensionActivators, IExtensionActivationService,
IExtensionActivator
Expand Down Expand Up @@ -69,10 +69,9 @@ export class ExtensionActivationService implements IExtensionActivationService,
let jedi = this.useJedi();
if (!jedi && !isLSSupported(this.serviceContainer)) {
this.appShell.showWarningMessage('The Python Language Server is not supported on your platform.');
const reporter = getTelemetryReporter();
// tslint:disable-next-line:no-suspicious-comment
// TODO: Only send once (ever)?
reporter.sendTelemetryEvent(PYTHON_LANGUAGE_SERVER_PLATFORM_NOT_SUPPORTED);
sendTelemetryEvent(PYTHON_LANGUAGE_SERVER_PLATFORM_NOT_SUPPORTED);
jedi = true;
}

Expand Down
7 changes: 3 additions & 4 deletions src/client/activation/languageServer/languageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import { StopWatch } from '../../common/utils/stopWatch';
import { IEnvironmentVariablesProvider } from '../../common/variables/types';
import { IServiceContainer } from '../../ioc/types';
import { LanguageServerSymbolProvider } from '../../providers/symbolProvider';
import { sendTelemetryEvent } from '../../telemetry';
import {
PYTHON_LANGUAGE_SERVER_ENABLED,
PYTHON_LANGUAGE_SERVER_ERROR
} from '../../telemetry/constants';
import { getTelemetryReporter } from '../../telemetry/telemetry';
import { IUnitTestManagementService } from '../../unittests/types';
import { LanguageServerDownloader } from '../downloader';
import { InterpreterData, InterpreterDataService } from '../interpreterDataService';
Expand Down Expand Up @@ -144,8 +144,7 @@ export class LanguageServerExtensionActivator implements IExtensionActivator {

private async startLanguageServer(clientOptions: LanguageClientOptions): Promise<boolean> {
// Determine if we are running MSIL/Universal via dotnet or self-contained app.
const reporter = getTelemetryReporter();
reporter.sendTelemetryEvent(PYTHON_LANGUAGE_SERVER_ENABLED);
sendTelemetryEvent(PYTHON_LANGUAGE_SERVER_ENABLED);

const settings = this.configuration.getSettings();
if (!settings.downloadLanguageServer) {
Expand All @@ -168,7 +167,7 @@ export class LanguageServerExtensionActivator implements IExtensionActivator {
return true;
} catch (ex) {
this.appShell.showErrorMessage(`Language server failed to start. Error ${ex}`);
reporter.sendTelemetryEvent(PYTHON_LANGUAGE_SERVER_ERROR, { error: 'Failed to start (platform)' });
sendTelemetryEvent(PYTHON_LANGUAGE_SERVER_ERROR, undefined, { error: 'Failed to start (platform)' });
return false;
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/client/common/nuget/azureBlobStoreNugetRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

'use strict';

import { common, createBlobServiceAnonymous } from 'azure-storage';
import * as azStorageTypes from 'azure-storage';
import { inject, injectable, unmanaged } from 'inversify';
import { IServiceContainer } from '../../ioc/types';
import { captureTelemetry } from '../../telemetry';
Expand All @@ -23,12 +23,14 @@ export class AzureBlobStoreNugetRepository implements INugetRepository {
@captureTelemetry(PYTHON_LANGUAGE_SERVER_LIST_BLOB_STORE_PACKAGES)
@log('Listing Nuget Packages', LogOptions.Arguments)
public listPackages(azureBlobStorageAccount: string, azureBlobStorageContainer: string, packageName: string) {
const blobStore = createBlobServiceAnonymous(azureBlobStorageAccount);
// tslint:disable-next-line:no-require-imports
const az = require('azure-storage') as typeof azStorageTypes;
const blobStore = az.createBlobServiceAnonymous(azureBlobStorageAccount);
const nugetService = this.serviceContainer.get<INugetService>(INugetService);
return new Promise<NugetPackage[]>((resolve, reject) => {
// We must pass undefined according to docs, but type definition doesn't all it to be undefined or null!!!
// tslint:disable-next-line:no-any
const token = undefined as any as common.ContinuationToken;
const token = undefined as any as azStorageTypes.common.ContinuationToken;
blobStore.listBlobsSegmentedWithPrefix(azureBlobStorageContainer, packageName, token,
(error, result) => {
if (error) {
Expand Down
7 changes: 5 additions & 2 deletions src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ if ((Reflect as any).metadata === undefined) {
// tslint:disable-next-line:no-require-imports no-var-requires
require('reflect-metadata');
}
const durations: { [key: string]: number } = {};
import { StopWatch } from './common/utils/stopWatch';
// Do not move this linne of code (used to measure extension load times).
const stopWatch = new StopWatch();
Expand Down Expand Up @@ -59,10 +60,12 @@ import { ICodeExecutionManager, ITerminalAutoActivation } from './terminals/type
import { TEST_OUTPUT_CHANNEL } from './unittests/common/constants';
import { registerTypes as unitTestsRegisterTypes } from './unittests/serviceRegistry';

durations.codeLoadingTime = stopWatch.elapsedTime;
const activationDeferred = createDeferred<void>();

// tslint:disable-next-line:max-func-body-length
export async function activate(context: ExtensionContext): Promise<IExtensionApi> {
durations.startActivateTime = stopWatch.elapsedTime;
const cont = new Container();
const serviceManager = new ServiceManager(cont);
const serviceContainer = new ServiceContainer(cont);
Expand Down Expand Up @@ -148,6 +151,7 @@ export async function activate(context: ExtensionContext): Promise<IExtensionApi
});

serviceContainer.get<IDebuggerBanner>(IDebuggerBanner).initialize();
durations.endActivateTime = stopWatch.elapsedTime;
activationDeferred.resolve();

return { ready: activationDeferred.promise };
Expand Down Expand Up @@ -197,7 +201,6 @@ async function sendStartupTelemetry(activatedPromise: Promise<void>, serviceCont
await activatedPromise;
const terminalHelper = serviceContainer.get<ITerminalHelper>(ITerminalHelper);
const terminalShellType = terminalHelper.identifyTerminalShell(terminalHelper.getTerminalShellPath());
const duration = stopWatch.elapsedTime;
const condaLocator = serviceContainer.get<ICondaService>(ICondaService);
const interpreterService = serviceContainer.get<IInterpreterService>(IInterpreterService);
const [condaVersion, interpreter, interpreters] = await Promise.all([
Expand All @@ -214,7 +217,7 @@ async function sendStartupTelemetry(activatedPromise: Promise<void>, serviceCont
.length > 0;

const props = { condaVersion, terminal: terminalShellType, pythonVersion, interpreterType, workspaceFolderCount, hasPython3 };
sendTelemetryEvent(EDITOR_LOAD, duration, props);
sendTelemetryEvent(EDITOR_LOAD, durations, props);
} catch (ex) {
logger.logError('sendStartupTelemetry failed.', ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class PythonPathUpdaterService implements IPythonPathUpdaterServiceManage
.catch<string>(() => '');
const [info, pipVersion] = await Promise.all([infoPromise, pipVersionPromise]);
if (info) {
telemtryProperties.pyVersion = info.version;
telemtryProperties.pythonVersion = info.version_info.join('.');
}
if (pipVersion) {
telemtryProperties.pipVersion = pipVersion;
Expand Down
30 changes: 26 additions & 4 deletions src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { isTestExecution } from '../common/constants';
// tslint:disable-next-line:no-reference
/// <reference path="./vscode-extension-telemetry.d.ts" />
import { extensions } from 'vscode';
// tslint:disable-next-line:import-name
import TelemetryReporter from 'vscode-extension-telemetry';
import { isTestExecution, PVSC_EXTENSION_ID } from '../common/constants';
import { StopWatch } from '../common/utils/stopWatch';
import { getTelemetryReporter } from './telemetry';
import { TelemetryProperties } from './types';

export function sendTelemetryEvent(eventName: string, durationMs?: number, properties?: TelemetryProperties) {
let telemetryReporter: TelemetryReporter;
function getTelemetryReporter() {
if (telemetryReporter) {
return telemetryReporter;
}
const extensionId = PVSC_EXTENSION_ID;
// tslint:disable-next-line:no-non-null-assertion
const extension = extensions.getExtension(extensionId)!;
// tslint:disable-next-line:no-unsafe-any
const extensionVersion = extension.packageJSON.version;
// tslint:disable-next-line:no-unsafe-any
const aiKey = extension.packageJSON.contributes.debuggers[0].aiKey;

// tslint:disable-next-line:no-require-imports
const reporter = require('vscode-extension-telemetry').default as typeof TelemetryReporter;
return telemetryReporter = new reporter(extensionId, extensionVersion, aiKey);
}

export function sendTelemetryEvent(eventName: string, durationMs?: { [key: string]: number } | number, properties?: TelemetryProperties) {
if (isTestExecution()) {
return;
}
const reporter = getTelemetryReporter();
const measures = typeof durationMs === 'number' ? { duration: durationMs } : undefined;
const measures = typeof durationMs === 'number' ? { duration: durationMs } : (durationMs ? durationMs : undefined);

// tslint:disable-next-line:no-any
const customProperties: { [key: string]: string } = {};
Expand Down
29 changes: 0 additions & 29 deletions src/client/telemetry/telemetry.ts

This file was deleted.

7 changes: 6 additions & 1 deletion src/client/telemetry/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export type LanguageServerTelemetry = {
lsVersion?: string;
};

export type LanguageServerErrorTelemetry = {
error: string;
};

export type LinterTrigger = 'auto' | 'save';

export type LintingTelemetry = {
Expand All @@ -31,7 +35,7 @@ export type LintingTelemetry = {
export type PythonInterpreterTelemetry = {
trigger: 'ui' | 'shebang' | 'load';
failed: boolean;
pyVersion?: string;
pythonVersion?: string;
pipVersion?: string;
};
export type CodeExecutionTelemetry = {
Expand Down Expand Up @@ -89,6 +93,7 @@ export type TerminalTelemetry = {
};
export type TelemetryProperties = FormatTelemetry
| LanguageServerTelemetry
| LanguageServerErrorTelemetry
| LintingTelemetry
| EditorLoadTelemetry
| PythonInterpreterTelemetry
Expand Down