Skip to content
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

Improved telemetry for Native Locator #23664

Merged
merged 4 commits into from
Jun 24, 2024
Merged

Conversation

DonJayamanne
Copy link

No description provided.

@DonJayamanne DonJayamanne added no-changelog No news entry required skip package*.json package.json and package-lock.json don't both need updating skip tests Updates to tests unnecessary labels Jun 24, 2024
@@ -106,13 +106,6 @@ class EnvironmentInfoService implements IEnvironmentInfoService {
}

const deferred = createDeferred<InterpreterInformation>();
const info = EnvironmentInfoService.getInterpreterInfo(env);
if (info !== undefined) {
this.cache.set(normCasePath(interpreterPath), deferred);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate PR for this #23662
Made the changes here to get stuff working, Found the above issue while working on this PR

}
}

if (env.version.major > -1 && env.version.minor > -1 && env.version.micro > -1 && env.location) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code

// However in the extension we treat this as an environment with an executable that can be `python` or `<fully resolved path to what we think will be the Python exe>`.
// However native locator will not return exes. Even though the env is detected.
// For those cases we'll look at the sysprefix.
let exe = env.executable.filename || '';
Copy link
Author

@DonJayamanne DonJayamanne Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here #23565 (comment)

@DonJayamanne DonJayamanne marked this pull request as ready for review June 24, 2024 06:41
@@ -262,129 +265,435 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection
private telemetrySentOnce = false;

private async sendTelemetry(query: PythonLocatorQuery | undefined, stopWatch: StopWatch) {
if (!query && !this.hasRefreshFinished(query)) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sending telemetry should have absolutely no impact on hasRefreFinished or even this.hasRefreshFinishedForQuery.set(query, true);
Hence moved the implementation code into a separate method sendTelemetryImpl.
That made the code simpler and also fixed the failing test.
I guess the problem was this.telemetrySentOnce was bailing early and not initializing the necessary flags (though not sure how this worked before this PR),

Either way, separating the two (i.e. separating the two concerns) fixes it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this method should be renamed and hasRefrehFinished should not be done here, at least IMHO, as this is telemetry.

@DonJayamanne DonJayamanne enabled auto-merge (squash) June 24, 2024 20:03
@DonJayamanne DonJayamanne force-pushed the betterNativeTelemetry2 branch from f0b4e82 to d92c2ed Compare June 24, 2024 21:02
@DonJayamanne DonJayamanne merged commit 2abec37 into main Jun 24, 2024
73 checks passed
@DonJayamanne DonJayamanne deleted the betterNativeTelemetry2 branch June 24, 2024 21:17
eleanorjboyd pushed a commit to eleanorjboyd/vscode-python that referenced this pull request Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog No news entry required skip package*.json package.json and package-lock.json don't both need updating skip tests Updates to tests unnecessary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants