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
Merged
Show file tree
Hide file tree
Changes from 202 commits
Commits
Show all changes
205 commits
Select commit Hold shift + click to select a range
b7399c5
rename existing command to openTerminal
Hweinstock Jul 7, 2023
588594d
add new command for ec2 instance remote-connect
Hweinstock Jul 7, 2023
1c57e45
register new command so that it does not throw error
Hweinstock Jul 7, 2023
814ba96
refactor to make terminal distinction clearer
Hweinstock Jul 7, 2023
b5d2c88
add prompt for new selection
Hweinstock Jul 7, 2023
08ba106
enable connection to ec2, start generalizing CodeCatalyst work
Hweinstock Jul 10, 2023
3caba57
abstract general error msg to its own function
Hweinstock Jul 10, 2023
f2894ba
refactor more code catalyst code
Hweinstock Jul 10, 2023
f0f5086
refactor code to better mirror the code catalyst implementaton
Hweinstock Jul 10, 2023
5be1f8d
add a cancellable loading bar on open
Hweinstock Jul 10, 2023
3c096cd
rename variable to be more explicit
Hweinstock Jul 10, 2023
13b2bc0
refactor to have a with-progress method layer
Hweinstock Jul 10, 2023
8fbbc8d
refactor ssh config into the ssh file
Hweinstock Jul 10, 2023
57dbde6
convert regExp property to abstract
Hweinstock Jul 10, 2023
fb9f1e8
reformat string in proxycommand
Hweinstock Jul 11, 2023
f94fe64
implement basic tests on sshconfig mock object
Hweinstock Jul 11, 2023
fdec798
split up verify ssh host into pieces
Hweinstock Jul 11, 2023
545b8a7
refactor the sshconfig to make more testable, add more tests
Hweinstock Jul 11, 2023
4f8c680
refactor tests to distinguish between command and proxyCommand
Hweinstock Jul 11, 2023
222fcfd
avoid hard-coding in test
Hweinstock Jul 11, 2023
0e5f7a2
avoid other hard-coding in tests
Hweinstock Jul 11, 2023
e87f24d
change simple function to be in lined
Hweinstock Jul 11, 2023
3764b4a
change command wording to be less clunky.
Hweinstock Jul 11, 2023
1c3be08
change command phrasing to mirror ssh extension
Hweinstock Jul 11, 2023
93e23f0
Merge branch 'hkobew/ec2/remoteConnect/newCommand' into hkobew/ec2/re…
Hweinstock Jul 11, 2023
d742eef
Merge branch 'hkobew/ec2/remoteConnect/connect' into hkobew/ec2/remot…
Hweinstock Jul 11, 2023
056e807
remove commented out code
Hweinstock Jul 12, 2023
153bf62
update command file with icon
Hweinstock Jul 13, 2023
bd71166
update context value for parent node
Hweinstock Jul 13, 2023
e027e40
handle case where parent node is passed to command
Hweinstock Jul 13, 2023
9d62154
change outdated prompter text
Hweinstock Jul 13, 2023
f28809b
refactor commands to own file
Hweinstock Jul 13, 2023
3cc9aa6
add start command to package.json files
Hweinstock Jul 13, 2023
732778f
add command to start the instance
Hweinstock Jul 13, 2023
2cbb723
fix typo in which method was being invoked
Hweinstock Jul 13, 2023
26faa78
merge upstream changes
Hweinstock Jul 13, 2023
ea30d86
refactor prompter and commands file
Hweinstock Jul 13, 2023
52a2fde
add tests for new structure of prompter
Hweinstock Jul 13, 2023
8fac525
refactor prompter code to be more testable
Hweinstock Jul 13, 2023
004ac0b
add baseline test to item provider
Hweinstock Jul 13, 2023
f85f0ee
add instance filter and tests for it
Hweinstock Jul 13, 2023
29d6b62
remove duplication of determining if instance is running
Hweinstock Jul 13, 2023
506be9a
backtrack filter idea because it breaks pagination
Hweinstock Jul 13, 2023
2022004
implement start command
Hweinstock Jul 13, 2023
8560da2
move bulk of work to new file
Hweinstock Jul 13, 2023
9022ec2
add command for stopping instance
Hweinstock Jul 13, 2023
fd1703d
add functionality to stop instances
Hweinstock Jul 13, 2023
9e0c16e
refactor start/stop commands into a class
Hweinstock Jul 13, 2023
1f53a3f
add testing for checking instance status
Hweinstock Jul 13, 2023
eb92609
add reboot command
Hweinstock Jul 13, 2023
cec3ede
implement reboot extension
Hweinstock Jul 13, 2023
024eb7b
refactor to remove duplicate code
Hweinstock Jul 13, 2023
38559be
remove unnecessary async
Hweinstock Jul 13, 2023
b217377
expose command on explorer
Hweinstock Jul 13, 2023
19ad794
refactor to eliminate some duplicate implementation
Hweinstock Jul 14, 2023
7794b67
handle undefined node consistently
Hweinstock Jul 14, 2023
adae37b
add method to append status to instance retriever
Hweinstock Jul 14, 2023
d3a4276
refactor how we add fields to the ec2 instances
Hweinstock Jul 14, 2023
0772dd2
add tests for new helper functions in Ec2Client
Hweinstock Jul 14, 2023
b4c03c3
refactor tests to use the same test-data
Hweinstock Jul 14, 2023
b76e22f
add test for filter functionality
Hweinstock Jul 14, 2023
98f03fb
change prompter to filter based on instance status
Hweinstock Jul 14, 2023
6cc4cc5
add icons to QuickPick
Hweinstock Jul 14, 2023
d147b22
disallow rebooting stopped instance
Hweinstock Jul 14, 2023
d72f9c9
add icon entrypoints to start/stop/restart commands
Hweinstock Jul 14, 2023
bd709da
move icon determiner function to seperate file
Hweinstock Jul 14, 2023
bffa367
add icons to show if its running in explorer
Hweinstock Jul 14, 2023
8062ed6
limit commands to cases where they are dont throw error
Hweinstock Jul 14, 2023
f7999b1
limit explorer icons and refresh after
Hweinstock Jul 14, 2023
f2a7786
fix outdated test
Hweinstock Jul 17, 2023
cf05c8e
remove commands from command palette
Hweinstock Jul 17, 2023
f0900d7
refactor such that it only updates ec2 parent node
Hweinstock Jul 17, 2023
10566c1
update outdated test
Hweinstock Jul 17, 2023
2b749a3
add testing to ec2InstanceNode
Hweinstock Jul 17, 2023
bf25145
add another test for the update functionality
Hweinstock Jul 17, 2023
de97b43
update tests to use icons
Hweinstock Jul 17, 2023
1914fe8
implement core logic with basic tests
Hweinstock Jul 17, 2023
ce7beb9
refactor to key by node, rather than string
Hweinstock Jul 17, 2023
a5cf7f3
switch back to using instanceids to add more testing
Hweinstock Jul 17, 2023
177aa07
ensure timer stops with tests
Hweinstock Jul 18, 2023
dd82ff9
refactor tests to avoid polling before tests start
Hweinstock Jul 18, 2023
76eb0fd
refactor such that only instance node is refreshed
Hweinstock Jul 18, 2023
5ad533f
no stopping/starting on pending instances
Hweinstock Jul 18, 2023
6efd4fd
refactor sshConfig changes to their own new file
Hweinstock Jul 18, 2023
4a68497
move the creation of ssh section to parent abstract class
Hweinstock Jul 18, 2023
ba21411
move ensureConnect to shared file
Hweinstock Jul 18, 2023
5ec5496
move ensure valid method to shared file
Hweinstock Jul 18, 2023
6c03515
remove sub-classes
Hweinstock Jul 18, 2023
7e6c56e
switch scriptPrefix to a parameter
Hweinstock Jul 18, 2023
19d3e2c
use variable to name prefix of script
Hweinstock Jul 18, 2023
886a41e
add test for section created by sshConfig
Hweinstock Jul 18, 2023
a4a4626
construct regexp from script name
Hweinstock Jul 18, 2023
8b36799
move logFile location generator to general file
Hweinstock Jul 18, 2023
72ae902
refactor the ec2_connect script
Hweinstock Jul 18, 2023
b08bbdb
refactor script to include token for session
Hweinstock Jul 18, 2023
c4348b4
include session tokens in script env
Hweinstock Jul 18, 2023
02b2a2b
adding suport for documents in start session
Hweinstock Jul 18, 2023
e373be8
remove port number
Hweinstock Jul 18, 2023
0f2c01d
remove log file location where unused
Hweinstock Jul 19, 2023
718c402
clean up state after tests
Hweinstock Jul 19, 2023
a21d6f8
hide start/stop/reboot from command palette
Hweinstock Jul 19, 2023
60566f5
add functionality to generate keys
Hweinstock Jul 19, 2023
e15c0a2
implement sending keys to target instance, with hard coded dest file
Hweinstock Jul 19, 2023
41eade4
implement reading public key from KeyPair
Hweinstock Jul 20, 2023
33fbd79
add comment about hard coded path
Hweinstock Jul 20, 2023
8cb386d
fix some spacing
Hweinstock Jul 20, 2023
84fa815
update config to get it working
Hweinstock Jul 20, 2023
dca607e
cleanup some small things
Hweinstock Jul 20, 2023
f6ac8e3
add some testing
Hweinstock Jul 20, 2023
e15e184
clean up handling of key parameters to ssh config
Hweinstock Jul 21, 2023
6950712
updates tests to utilize sinon stub
Hweinstock Jul 21, 2023
d951675
remove references to code catatlyst in error/log messages
Hweinstock Jul 21, 2023
2a63ae3
pass remote username down from above
Hweinstock Jul 21, 2023
1087678
increase testing coverage for sshConfigSection
Hweinstock Jul 21, 2023
84ea20a
implement method to determine remote user
Hweinstock Jul 21, 2023
eed3a09
implement method for guessing the os
Hweinstock Jul 21, 2023
4b94c83
refactor to use ssm sdk to determine os
Hweinstock Jul 21, 2023
65ad6ac
check for permissions before trying the ssm sdk
Hweinstock Jul 21, 2023
febac95
fix to work on ubuntu
Hweinstock Jul 21, 2023
ee149b7
remove leftover log statement
Hweinstock Jul 21, 2023
d70c415
merge in master
Hweinstock Jul 21, 2023
aa56c93
refactor tests to use stub only where needed
Hweinstock Jul 24, 2023
90b248b
remove double restore in test file
Hweinstock Jul 24, 2023
950ca3c
test commenting out sshConfig tests
Hweinstock Jul 24, 2023
f17580d
add comment to import so that it runs
Hweinstock Jul 24, 2023
ac4e711
comment out other use of sinon stub for testing
Hweinstock Jul 24, 2023
7441de1
comment out test for reading ssh keys
Hweinstock Jul 24, 2023
ef427f2
comment out tests in the model file
Hweinstock Jul 24, 2023
a0cea9d
comment out entire codecatalyst tools file
Hweinstock Jul 24, 2023
740baf8
comment out all tests modified
Hweinstock Jul 24, 2023
c60d540
uncomment test files
Hweinstock Jul 24, 2023
2a08bb7
move ssh tests to their own file
Hweinstock Jul 24, 2023
24a25d0
uncomment tests related to the model
Hweinstock Jul 24, 2023
27179ab
move the rest of the the tests to the sshConfig file
Hweinstock Jul 24, 2023
a8a92ae
add codecatalyst label to relevant tests
Hweinstock Jul 24, 2023
d6896c1
rename file to mirror main class name in file
Hweinstock Jul 24, 2023
e201693
rename test file
Hweinstock Jul 24, 2023
3bbabd1
change path import structure
Hweinstock Jul 24, 2023
59e9f9c
merge in master
Hweinstock Jul 27, 2023
58f6ff6
merge in master
Hweinstock Jul 27, 2023
f4cccca
merge master
Hweinstock Jul 28, 2023
8e281cd
fix duplicate declaration error
Hweinstock Jul 31, 2023
54ed468
separate return statement from body of return.
Hweinstock Aug 3, 2023
c8f5cd3
attach sdout to error
Hweinstock Aug 3, 2023
aab45f7
merge in master
Hweinstock Aug 4, 2023
ba6afbf
fix failing tests
Hweinstock Aug 5, 2023
b10b74c
Merge branch 'hkobew/ec2/remoteConnect/sshKeysNew' of https://github.…
Hweinstock Aug 5, 2023
57ad523
handle merge conflicts
Hweinstock Aug 5, 2023
dd05a0d
remove duplicate commands
Hweinstock Aug 5, 2023
08a1087
Merge branch 'master' into hkobew/ec2/remoteConnect/explorer
Hweinstock Aug 7, 2023
ce8db34
add icon back for terminal on explorer
Hweinstock Aug 7, 2023
eb4ed03
Merge branch 'hkobew/ec2/remoteConnect/sshKeysNew' into hkobew/ec2/re…
Hweinstock Aug 7, 2023
7c0e57d
expose command on explorer
Hweinstock Aug 7, 2023
40abd17
merge in upstream changes
Hweinstock Aug 7, 2023
ae3851c
merge in master
Hweinstock Aug 8, 2023
9cbcb48
remove duplicate commands in package.json
Hweinstock Aug 8, 2023
4d6cd41
remove duplicate terminal command
Hweinstock Aug 8, 2023
d4a2244
merge in master
Hweinstock Aug 10, 2023
ac6d473
make instance readonly on instance node
Hweinstock Aug 10, 2023
e40064a
merge in master
Hweinstock Aug 10, 2023
292bc56
fix merge errors in duplicate commands
Hweinstock Aug 10, 2023
3eeba07
enable utility functions on pending nodes
Hweinstock Aug 10, 2023
3e73b23
remove dead files
Hweinstock Aug 10, 2023
6cab577
add comment about not-readonly
Hweinstock Aug 10, 2023
a034dc3
refactor to allow for readonly instance with comment
Hweinstock Aug 10, 2023
60e1d41
add telemetry for remote connection through vscode
Hweinstock Aug 10, 2023
f58867d
add new type on ec2connect metric to track interface
Hweinstock Aug 11, 2023
2854015
merge in master
Hweinstock Aug 11, 2023
f21201f
merge in master, update imports
Sep 5, 2024
c9d6eff
update vscode.command usage
Hweinstock Sep 5, 2024
49efa8b
add changelog
Hweinstock Sep 5, 2024
0cc83e3
start to generalize polling set
Hweinstock Sep 5, 2024
996362c
minimize code dupe
Hweinstock Sep 5, 2024
1e6cdcf
cleanup
Hweinstock Sep 5, 2024
4e97666
generalize further, extend tests
Hweinstock Sep 5, 2024
9d9fa8d
fix linting problems
Hweinstock Sep 5, 2024
79b8f81
fix linting 2
Hweinstock Sep 6, 2024
681771e
Merge branch 'master' into hkobew/ec2/explorerUpdate
Hweinstock Sep 6, 2024
955308c
clean up inlining
Hweinstock Sep 6, 2024
6c30851
merge upstream changes
Hweinstock Sep 6, 2024
b77dc8d
move test files over
Hweinstock Sep 12, 2024
548f69e
move rest of changes from other branch
Hweinstock Sep 12, 2024
f152943
fix imports
Hweinstock Sep 12, 2024
1af46cd
update changelog
Hweinstock Sep 12, 2024
f6b805e
merge in upstream changes
Hweinstock Sep 12, 2024
f1c6fee
move over changes
Hweinstock Sep 12, 2024
727d7a5
Merge branch 'hkobew/ec2/remoteConnect/telemetry' into hkobew/ec2/rem…
Hweinstock Sep 12, 2024
5aabfde
merge in upstream changes
Hweinstock Sep 16, 2024
0382de6
Merge branch 'master' into hkobew/ec2/remoteConnect/telemetry
Hweinstock Sep 17, 2024
7311f0d
Merge branch 'master' into hkobew/ec2/remoteConnect/telemetry
Hweinstock Oct 16, 2024
58c611a
Merge branch 'master' into hkobew/ec2/remoteConnect/telemetry
Hweinstock Oct 17, 2024
64c9e5a
Merge branch 'master' into hkobew/ec2/remoteConnect/telemetry
Hweinstock Oct 21, 2024
3dae58c
remove temp check
Hweinstock Oct 21, 2024
ea2a1ce
add tests for telemetry
Hweinstock Oct 21, 2024
026d39d
Merge branch 'master' into hkobew/ec2/remoteConnect/telemetry
Hweinstock Oct 22, 2024
ceba452
bump telemetry version
Hweinstock Oct 22, 2024
59cdd21
Merge branch 'master' into hkobew/ec2/remoteConnect/telemetry
Hweinstock Oct 23, 2024
4823d91
Merge branch 'master' into hkobew/ec2/remoteConnect/telemetry
Hweinstock Oct 23, 2024
f5f82c9
disable polling set
Hweinstock Oct 25, 2024
0cc31e3
restore stubs afterwards
Hweinstock Oct 25, 2024
16492c2
merge in upstream
Hweinstock Oct 29, 2024
26b25bf
rename tests to be general activation tests
Hweinstock Oct 29, 2024
1bfde6b
merge master
Hweinstock Nov 7, 2024
6b9eb69
move telemetry into a single test
Hweinstock Nov 7, 2024
1e086f0
Merge branch 'master' into hkobew/ec2/remoteConnect/telemetry
Hweinstock Nov 7, 2024
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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"generateNonCodeFiles": "npm run generateNonCodeFiles -w packages/ --if-present"
},
"devDependencies": {
"@aws-toolkits/telemetry": "^1.0.272",
"@aws-toolkits/telemetry": "^1.0.273",
"@playwright/browser-chromium": "^1.43.1",
"@types/he": "^1.2.3",
"@types/vscode": "^1.68.0",
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/awsService/ec2/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export async function activate(ctx: ExtContext): Promise<void> {
}),

Commands.register('aws.ec2.openRemoteConnection', async (node?: Ec2Node) => {
await openRemoteConnection(connectionManagers, node)
await telemetry.ec2_connectToInstance.run(async (span) => {
span.record({ ec2ConnectionType: 'remoteWorkspace' })
await openRemoteConnection(connectionManagers, node)
})
}),

Commands.register('aws.ec2.startInstance', async (node?: Ec2Node) => {
Expand Down
73 changes: 73 additions & 0 deletions packages/core/src/test/awsService/ec2/activation.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
import * as vscode from 'vscode'
import * as sinon from 'sinon'
import { assertTelemetry } from '../../testUtil'
import { Ec2InstanceNode } from '../../../awsService/ec2/explorer/ec2InstanceNode'
import { Ec2ParentNode } from '../../../awsService/ec2/explorer/ec2ParentNode'
import { Ec2Client } from '../../../shared/clients/ec2Client'
import { Ec2Connecter } from '../../../awsService/ec2/model'
import { PollingSet } from '../../../shared/utilities/pollingSet'

describe('ec2 activation', function () {
let testNode: Ec2InstanceNode

before(function () {
const testRegion = 'test-region'
const testPartition = 'test-partition'
// Don't want to be polling here, that is tested in ../ec2ParentNode.test.ts
// disabled here for convenience (avoiding race conditions with timeout)
sinon.stub(PollingSet.prototype, 'start')
const testClient = new Ec2Client(testRegion)
const parentNode = new Ec2ParentNode(testRegion, testPartition, new Ec2Client(testRegion))
testNode = new Ec2InstanceNode(parentNode, testClient, testRegion, testPartition, {
InstanceId: 'testId',
LastSeenStatus: 'status',
})
})

after(function () {
sinon.restore()
})
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.


it('state stop', async function () {
const stopInstanceStub = sinon.stub(Ec2Client.prototype, 'stopInstanceWithCancel')
await vscode.commands.executeCommand('aws.ec2.stopInstance', testNode)

assertTelemetry('ec2_changeState', { ec2InstanceState: 'stop' })
stopInstanceStub.restore()
})

it('state start', async function () {
const startInstanceStub = sinon.stub(Ec2Client.prototype, 'startInstance')
await vscode.commands.executeCommand('aws.ec2.startInstance', testNode)

assertTelemetry('ec2_changeState', { ec2InstanceState: 'start' })
startInstanceStub.restore()
})

it('state reboot', async function () {
const rebootInstanceStub = sinon.stub(Ec2Client.prototype, 'rebootInstance')
await vscode.commands.executeCommand('aws.ec2.rebootInstance', testNode)

assertTelemetry('ec2_changeState', { ec2InstanceState: 'reboot' })
rebootInstanceStub.restore()
})
})
Loading