Skip to content

Add the CLI version to telemetry events #2307

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 4 commits into from
Apr 18, 2023

Conversation

aeisenberg
Copy link
Contributor

This adds the CLI version to telemetry command-usage events.

Note that the CLI server is created after the telemetry listener is created. The first few telemetry events may have a "not-set" value for the CLI version.

Checklist

  • [n/a] CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [n/a] [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

@aeisenberg aeisenberg requested a review from a team as a code owner April 12, 2023 23:35
This adds the CLI version to telemetry command-usage events.

Note that the CLI server is created after the telemetry listener is
created. The first few telemetry events may have a "not-set" value for
the CLI version.
@aeisenberg aeisenberg force-pushed the aeisenberg/cli-version-telemetry branch from 9c99553 to d6b3e51 Compare April 13, 2023 02:06
Copy link
Member

@koesie10 koesie10 left a comment

Choose a reason for hiding this comment

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

Thanks for adding this, this will definitely be useful!

I'm somewhat concerned about the performance impact this will have on sending commands. If there is no version available, this will spawn a process to get the CLI version, which might delay the telemetry and possibly skip sending the telemetry if VS Code gets closed early.

I also think the CLI version would be useful on other telemetry events (especially errors). I think it would be good if we could use a addTelemetryProcessor to add the CLI version tag to every telemetry event we send. The telemetry processor is not async, but we could use the cached CLI version here. That would also solve my concern about performance. We should already always be retrieving the version in the CLI server (since it's also used by CLI version constraints and the status bar), so I think this would be a very viable option for adding the CLI version to all telemetry events without the possibility of spawning a process on every telemetry event.

@robertbrignull
Copy link
Contributor

I agree with Koen's points. Calculating the CLI version while handling the telemetry event doesn't seem great, both in terms of performance and the chance of errors happening and stopping us sending telemetry. Could we set the CLI version once, and then maybe update it if the CLI changes? I also agree it would be nice to have this on all events, like how we include isCanary.

@aeisenberg
Copy link
Contributor Author

Thanks for the feedback. I will change my approach. I'll add a callback to the CliServer that gets invoked whenever the CLI version changes. There will still be a time at startup when the cli version is not known since the telemetry listener is instantiated before the cli server (sometimes this takes a while).

I can also add the cli version to all telemetry events.

Set the CLI version in the telemetry listener whenever the version
changes.

A few things to note here:

1. In `CliServer::getVersion()`, avoid calling `supportsPerQueryEvalLog`
   directly. This avoids a recursive call to `CliServer::getVersion()`.
   Currently, it's always safe to do this, but I thought that it would
   be good to avoid recursion here in case we change things in the
   future.
2. Now, we are sending the CLI version with all telemetry events.
@aeisenberg aeisenberg requested a review from koesie10 April 13, 2023 19:17
@aeisenberg
Copy link
Contributor Author

I think I addressed all the comments.

@aeisenberg
Copy link
Contributor Author

aeisenberg commented Apr 13, 2023

Not sure why I'm getting a failing test:

https://github.com/github/vscode-codeql/actions/runs/4693003381/jobs/8320617631#step:9:69

It doesn't seem related to my changes, but it is repeatable in CI.

Looks like this job on main failed in a similar way: https://github.com/github/vscode-codeql/actions/runs/4690867136/jobs/8314564124

@aeisenberg
Copy link
Contributor Author

Maybe updating the branch will help.

@aeisenberg
Copy link
Contributor Author

Nope.

@robertbrignull
Copy link
Contributor

I'd guess we have some tests that are very close to the timeout value, and they've just tipped over recently 😢

@robertbrignull
Copy link
Contributor

We have an internal issue about tests timing out and I've mentioned this there. Either we should look at making the tests faster or raising the timeout value.

Copy link
Member

@koesie10 koesie10 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for addressing our concerns!

Copy link
Contributor

@robertbrignull robertbrignull left a comment

Choose a reason for hiding this comment

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

LGTM too

@aeisenberg
Copy link
Contributor Author

Here's my analysis:

The first error was indeed a timeout error:

    thrown: "Exceeded timeout of 20000 ms for a test.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

The tests re-ran and somewhere during the retry, the original query finally completed, but the callback failed since the connection had already been disposed. So, I think increasing the timeout will work, and we should also figure out a way to properly cancel a query in the teardown.

Also, I found another error where removeAllDatabases throws. This method is called during teardown and makes a call to the query server to de-register the database. If the query server is already shut down, then an error will be thrown. But if the query server is shut down, then deregistering isn't necessary, so it's ok to ignore.

I will put a fix in for this and bump the timeouts. Both will be in a separate PR.

@aeisenberg
Copy link
Contributor Author

I attempt to address this and some related concerns here: #2331

@aeisenberg aeisenberg merged commit 72a3e8d into main Apr 18, 2023
@aeisenberg aeisenberg deleted the aeisenberg/cli-version-telemetry branch April 18, 2023 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants