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

telemetry(ec2): add more detailed metric on remote VSCode connection. #3723

Merged
merged 205 commits into from
Nov 8, 2024

Conversation

Hweinstock
Copy link
Contributor

@Hweinstock Hweinstock commented Aug 10, 2023

Problem

Solution

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Hweinstock and others added 30 commits July 7, 2023 14:03
Co-authored-by: JadenSimon <31319484+JadenSimon@users.noreply.github.com>
Copy link

This pull request modifies code in src/ but no tests were added/updated. Confirm whether tests should be added or ensure the PR description explains why tests are not required.

@Hweinstock
Copy link
Contributor Author

Hweinstock commented Oct 21, 2024

Do I need to wait until next release of https://github.com/aws/aws-toolkit-common for this to not fail?

@justinmk3
Copy link
Contributor

aws/aws-toolkit-common@533415f was released in aws/aws-toolkit-common@49de773 (1.0.273).

So updating the dependency here to 1.0.273 or later should work.

@justinmk3
Copy link
Contributor

linux ci found unhandled promise rejections

rejected promise not handled within 1 second: Error: Node with id testId from polling set not found
rejected promise not handled within 1 second: Error: Node with id testId from polling set not found

ERROR: Test output matched this pattern 3 times:
       "rejected promise not handled"
       This typically indicates a bug. Read https://developer.mozilla.org/docs/Web/JavaScript/Guide/Using_promises#error_handling

@Hweinstock
Copy link
Contributor Author

Ahhhh, forgot to disable the timer in the new tests. I feel like how I implemented the PollingSet as part of the class is becoming a code smell, with how it makes tests flaky if you aren't careful. Do you see a way to simplify it, and avoid the need the disable the polling whenever testing?

Comment on lines 34 to 48
it('terminal open', async function () {
const terminalStub = sinon.stub(Ec2Connecter.prototype, 'attemptToOpenEc2Terminal')
await vscode.commands.executeCommand('aws.ec2.openTerminal', testNode)

assertTelemetry('ec2_connectToInstance', { ec2ConnectionType: 'ssm' })
terminalStub.restore()
})

it('remote window open', async function () {
const remoteWindowStub = sinon.stub(Ec2Connecter.prototype, 'tryOpenRemoteConnection')
await vscode.commands.executeCommand('aws.ec2.openRemoteConnection', testNode)

assertTelemetry('ec2_connectToInstance', { ec2ConnectionType: 'remoteWorkspace' })
remoteWindowStub.restore()
})
Copy link
Contributor

@justinmk3 justinmk3 Nov 1, 2024

Choose a reason for hiding this comment

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

if these tests have stubbed the command so that it does nothing useful, then they could all be one it('telemetry') test (note: the describe() is still "general", but just a single it() test is for testing telemetry specifically).

Alternatively, if there are existing tests for these commands, can't those existing tests call assertTelemetry ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The high-level commands are simply wrappers around the logic that is tested in https://github.com/aws/aws-toolkit-vscode/blob/142761e268dd48687d0f696f6ded22819c74ffc7/packages/core/src/test/awsService/ec2/model.test.ts. The only difference at this level is the prompting logic (tested in https://github.com/aws/aws-toolkit-vscode/blob/142761e268dd48687d0f696f6ded22819c74ffc7/packages/core/src/test/awsService/ec2/prompter.test.ts) and telemetry (tested here). It doesn't seem to me to make sense to test any E2E aspects of the code beyond telemetry here.

@justinmk3 justinmk3 merged commit 30f9289 into master Nov 8, 2024
18 of 25 checks passed
@justinmk3 justinmk3 deleted the hkobew/ec2/remoteConnect/telemetry branch November 8, 2024 00:26
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.

2 participants