forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add telemetry reporting on VS analysis engine usage #1382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
a764bc9
Undo changes
9d1b2cc
Test fixes
a91291a
Increase timeout
bf266af
Remove double event listening
7bc6bd6
Remove test
8ce8b48
Revert "Remove test"
e3a549e
Revert "Remove double event listening"
92e8c1e
#1096 The if statement is automatically formatted incorrectly
b540a1d
Merge fix
7b0573e
Add more tests
facb106
More tests
f113881
Typo
3e76718
Test
6e85dc6
Also better handle multiline arguments
99e037c
Add a couple missing periods
brettcannon 3caeab7
Undo changes
eeb1f11
Test fixes
f5f78c7
Increase timeout
88744da
Remove double event listening
65dde44
Remove test
c513f71
Revert "Remove test"
ccb3886
Revert "Remove double event listening"
106f4db
Merge fix
9e5cb43
Merge branch 'master' of https://github.com/MikhailArkhipov/vscode-py…
e1da6a6
#1257 On type formatting errors for args and kwargs
e78f0fb
Handle f-strings
725cf71
Stop importing from test code
5cd6d45
#1308 Single line statements leading to an indentation on the next line
27613db
#726 editing python after inline if statement invalid indent
8061a20
Undo change
17dc292
Move constant
65964b9
Harden LS startup error checks
4bf5a4c
#1364 Intellisense doesn't work after specific const string
6f7212c
Merge branch 'master' of https://github.com/Microsoft/vscode-python
ddbd295
Telemetry for the analysis enging
ffd1d3f
Merge branch 'master' of https://github.com/Microsoft/vscode-python
d4afb6c
PR feedback
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,13 @@ import { IProcessService } from '../common/process/types'; | |
import { StopWatch } from '../common/stopWatch'; | ||
import { IConfigurationService, IOutputChannel, IPythonSettings } from '../common/types'; | ||
import { IServiceContainer } from '../ioc/types'; | ||
import { | ||
PYTHON_ANALYSIS_ENGINE_DOWNLOADED, | ||
PYTHON_ANALYSIS_ENGINE_ENABLED, | ||
PYTHON_ANALYSIS_ENGINE_ERROR, | ||
PYTHON_ANALYSIS_ENGINE_STARTUP | ||
} from '../telemetry/constants'; | ||
import { getTelemetryReporter } from '../telemetry/telemetry'; | ||
import { AnalysisEngineDownloader } from './downloader'; | ||
import { InterpreterDataService } from './interpreterDataService'; | ||
import { PlatformData } from './platformData'; | ||
|
@@ -26,7 +33,7 @@ const analysisEngineFolder = 'analysis'; | |
class LanguageServerStartupErrorHandler implements ErrorHandler { | ||
constructor(private readonly deferred: Deferred<void>) { } | ||
public error(error: Error, message: Message, count: number): ErrorAction { | ||
this.deferred.reject(); | ||
this.deferred.reject(error); | ||
return ErrorAction.Shutdown; | ||
} | ||
public closed(): CloseAction { | ||
|
@@ -71,6 +78,9 @@ export class AnalysisExtensionActivator implements IExtensionActivator { | |
const mscorlib = path.join(context.extensionPath, analysisEngineFolder, 'mscorlib.dll'); | ||
let downloadPackage = false; | ||
|
||
const reporter = getTelemetryReporter(); | ||
reporter.sendTelemetryEvent(PYTHON_ANALYSIS_ENGINE_ENABLED); | ||
|
||
if (!await this.fs.fileExistsAsync(mscorlib)) { | ||
// Depends on .NET Runtime or SDK | ||
this.languageClient = this.createSimpleLanguageClient(context, clientOptions); | ||
|
@@ -80,6 +90,7 @@ export class AnalysisExtensionActivator implements IExtensionActivator { | |
} catch (ex) { | ||
if (await this.isDotNetInstalled()) { | ||
this.appShell.showErrorMessage(`.NET Runtime appears to be installed but the language server did not start. Error ${ex}`); | ||
reporter.sendTelemetryEvent(PYTHON_ANALYSIS_ENGINE_ERROR, { error: 'Failed to start (MSIL)' }); | ||
return false; | ||
} | ||
// No .NET Runtime, no mscorlib - need to download self-contained package. | ||
|
@@ -90,6 +101,7 @@ export class AnalysisExtensionActivator implements IExtensionActivator { | |
if (downloadPackage) { | ||
const downloader = new AnalysisEngineDownloader(this.services, analysisEngineFolder); | ||
await downloader.downloadAnalysisEngine(context); | ||
reporter.sendTelemetryEvent(PYTHON_ANALYSIS_ENGINE_DOWNLOADED); | ||
} | ||
|
||
const serverModule = path.join(context.extensionPath, analysisEngineFolder, this.platformData.getEngineExecutableName()); | ||
|
@@ -100,6 +112,7 @@ export class AnalysisExtensionActivator implements IExtensionActivator { | |
return true; | ||
} catch (ex) { | ||
this.appShell.showErrorMessage(`Language server failed to start. Error ${ex}`); | ||
reporter.sendTelemetryEvent(PYTHON_ANALYSIS_ENGINE_ERROR, { error: 'Failed to start (platform)' }); | ||
return false; | ||
} | ||
} | ||
|
@@ -108,16 +121,20 @@ export class AnalysisExtensionActivator implements IExtensionActivator { | |
let disposable: Disposable | undefined; | ||
const deferred = createDeferred<void>(); | ||
try { | ||
const sw = new StopWatch(); | ||
lc.clientOptions.errorHandler = new LanguageServerStartupErrorHandler(deferred); | ||
|
||
disposable = lc.start(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. disposable = lc.start();
lc.onReady()
.then(() => deferred.resolve())
.catch(ex => deferred.reject());
await deferred.promise; You might want to change to |
||
lc.onReady() | ||
.then(() => deferred.resolve()) | ||
.catch(ex => deferred.reject()); | ||
.catch(deferred.reject); | ||
await deferred.promise; | ||
|
||
this.output.appendLine(`Language server ready: ${this.sw.elapsedTime} ms`); | ||
context.subscriptions.push(disposable); | ||
|
||
const reporter = getTelemetryReporter(); | ||
reporter.sendTelemetryEvent(PYTHON_ANALYSIS_ENGINE_STARTUP, {}, { startup_time: sw.elapsedTime }); | ||
} catch (ex) { | ||
if (disposable) { | ||
disposable.dispose(); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍