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(lsp): Integrate language server/manifest resolver telemetry #6385

Merged
merged 45 commits into from
Feb 6, 2025
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
75a4d43
define metric within VSC telemetry
Hweinstock Jan 16, 2025
191e0ea
implement telemetry for fetching stage
Hweinstock Jan 16, 2025
0b4cec4
lift telemetry logic to top level
Hweinstock Jan 16, 2025
3727ea9
add telemetry for remaining stages
Hweinstock Jan 16, 2025
5d5a7d8
seperate verification and downloading
Hweinstock Jan 17, 2025
a7b446d
add telemetry for validation step
Hweinstock Jan 17, 2025
3304e99
rename metrics and types
Hweinstock Jan 17, 2025
45b0236
reduce duplication across stage implementations
Hweinstock Jan 17, 2025
c2596cf
undo unnecessary change
Hweinstock Jan 17, 2025
4f2b662
Merge branch 'feature/amazonqLSP' into telemetry/setup
Hweinstock Jan 21, 2025
6ef6633
switch to fallback instead of cache when remote option fails
Hweinstock Jan 21, 2025
3b3b39b
fix telemetry metadata field
Hweinstock Jan 23, 2025
abdb5fd
port metrics down from commons until release
Hweinstock Jan 23, 2025
0aadddf
implement logic for manifest telemetry
Hweinstock Jan 23, 2025
f03bf8d
Merge branch 'feature/amazonqLSP' into telemetry/setup
Hweinstock Jan 24, 2025
7d05c68
telemetry: implement logic for server resolution
Hweinstock Jan 24, 2025
c7b97e2
refactor: move tryFunctions to core and include tests
Hweinstock Jan 24, 2025
5284763
telemtry: implement telemetry for amazonQLSP
Hweinstock Jan 24, 2025
7dfefe6
test: implement tests for manifestResolver
Hweinstock Jan 24, 2025
bad6697
Merge branch 'feature/amazonqLSP' into telemetry/setup
Hweinstock Jan 24, 2025
4b1e90a
refactor: simplify lspResolver implementation
Hweinstock Jan 24, 2025
45901e7
test: add tests for lsp resolver (WIP)
Hweinstock Jan 24, 2025
2ee4792
test: add tests for lspResolver
Hweinstock Jan 27, 2025
3a6bad2
test: remove duplicate data in tests
Hweinstock Jan 27, 2025
9e708fd
refactor: move telemetry work to more general location
Hweinstock Jan 27, 2025
0b4da9d
fix: change outdated reference
Hweinstock Jan 27, 2025
c37ef4a
merge: bring in HttpResourceFetcher changes
Hweinstock Jan 27, 2025
9cee3e7
refactor: rename stage -> setupStage
Hweinstock Jan 27, 2025
05f3a2b
fix: add workaround for windows tests
Hweinstock Jan 27, 2025
80fa5d6
test: disable lspResolver test on nonmac, add techdebt test
Hweinstock Jan 27, 2025
8ebcc97
jscpd: ignore verbose telemetry checks
Hweinstock Jan 27, 2025
3cf254a
refactor: avoid duplicate import line
Hweinstock Jan 27, 2025
2c60608
merge: handle tsUtils conflicts
Hweinstock Jan 28, 2025
9b9443b
deps: bump telemetry version and remove local changes
Hweinstock Jan 28, 2025
077e402
refactor: cleanup minor details
Hweinstock Jan 28, 2025
0ef9f0d
merge: resolve conflicts
Hweinstock Jan 29, 2025
b0a37f3
refactor: fix spelling mistake
Hweinstock Feb 3, 2025
42ed745
fix: remove accidental space
Hweinstock Feb 3, 2025
ea4e35a
Merge branch 'feature/amazonqLSP' into telemetry/setup
Hweinstock Feb 3, 2025
d286070
test: add telemetry to e2e tests
Hweinstock Feb 4, 2025
3888ac5
test: adjust telemetry to mirror CI reality
Hweinstock Feb 4, 2025
4819d49
test: adjust results to mirror ci
Hweinstock Feb 4, 2025
3aa2670
test: delete duplicate coverage test case
Hweinstock Feb 5, 2025
e55dd7f
test: avoid bleedthrough of globalstate
Hweinstock Feb 5, 2025
8bc7ccc
test: ensure consistent global storage state to ensure consistent beh…
Hweinstock Feb 5, 2025
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
Prev Previous commit
Next Next commit
lift telemetry logic to top level
Hweinstock committed Jan 16, 2025
commit 0b4cec40d1addf44b9b2d2394bfa05694488f38d
32 changes: 26 additions & 6 deletions packages/core/src/amazonq/lsp/workspaceInstaller.ts
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ import { LanguageServerResolver } from '../../shared/lsp/lspResolver'
import { Range } from 'semver'
import { getNodeExecutableName } from '../../shared/lsp/utils/platform'
import { fs } from '../../shared/fs/fs'
import { telemetry } from '../../shared/telemetry'

const manifestUrl = 'https://aws-toolkit-language-servers.amazonaws.com/q-context/manifest.json'
// this LSP client in Q extension is only going to work with these LSP server versions
@@ -18,12 +19,31 @@ const supportedLspServerVersions = '0.1.32'
export class WorkspaceLSPResolver implements LspResolver {
async resolve(): Promise<LspResolution> {
const name = 'AmazonQ-Workspace'
const manifest = await new ManifestResolver(manifestUrl, name).resolve()
const installationResult = await new LanguageServerResolver(
manifest,
name,
new Range(supportedLspServerVersions)
).resolve()
const manifest = await telemetry.lsp_setup.run(async (span) => {
const startTime = performance.now()
span.record({ lspSetupStage: 'fetchManifest' })
const result = await new ManifestResolver(manifestUrl, name).resolve()
span.record({
lspSetupLocation: result.location ?? 'unknown',
duration: performance.now() - startTime,
})
return result
})

const installationResult = await telemetry.lsp_setup.run(async (span) => {
const startTime = performance.now()
span.record({ lspSetupStage: 'serverCall' })
const result = await new LanguageServerResolver(
manifest,
name,
new Range(supportedLspServerVersions)
).resolve()
span.record({
lspSetupLocation: result.location ?? 'unknown',
duration: performance.now() - startTime,
})
return result
})

const nodeName =
process.platform === 'win32' ? getNodeExecutableName() : `node-${process.platform}-${process.arch}`
24 changes: 7 additions & 17 deletions packages/core/src/shared/lsp/manifestResolver.ts
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ import { RetryableResourceFetcher } from '../resourcefetcher/httpResourceFetcher
import { Timeout } from '../utilities/timeoutUtils'
import globals from '../extensionGlobals'
import { Manifest } from './types'
import { telemetry } from '../telemetry'

const logger = getLogger('lsp')

@@ -33,22 +32,11 @@ export class ManifestResolver {
* Fetches the latest manifest, falling back to local cache on failure
*/
async resolve(): Promise<Manifest> {
return await telemetry.lsp_setup.run(async (span) => {
span.record({ lspSetupStage: 'fetchManifest' })
const startTime = performance.now()

try {
const result = await this.fetchRemoteManifest()
span.record({ lspSetupLocation: 'remote' })
return result
} catch (error) {
span.record({ lspSetupLocation: 'cache' })
const result = await this.getLocalManifest()
return result
} finally {
span.record({ duration: performance.now() - startTime })
}
})
try {
return await this.fetchRemoteManifest()
} catch (error) {
return await this.getLocalManifest()
}
}

private async fetchRemoteManifest(): Promise<Manifest> {
@@ -67,6 +55,7 @@ export class ManifestResolver {
const manifest = this.parseManifest(resp.content)
await this.saveManifest(resp.eTag, resp.content)
this.checkDeprecation(manifest)
manifest.location = 'remote'
return manifest
}

@@ -81,6 +70,7 @@ export class ManifestResolver {

const manifest = this.parseManifest(manifestData.content)
this.checkDeprecation(manifest)
manifest.location = 'cache'
return manifest
}

1 change: 1 addition & 0 deletions packages/core/src/shared/lsp/types.ts
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ export interface Manifest {
artifactDescription: string
isManifestDeprecated: boolean
versions: LspVersion[]
location?: Location
}

export interface VersionRange {
2 changes: 1 addition & 1 deletion packages/core/src/shared/telemetry/vscodeTelemetry.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
{
"name": "lspSetupLocation",
"type": "string",
"allowedValues": ["cache", "remote", "fallback", "override"],
"allowedValues": ["cache", "remote", "fallback", "override", "unknown"],
"description": "The location of the LSP server"
},
{
49 changes: 0 additions & 49 deletions packages/core/src/test/shared/lsp/manifestResolver.test.ts

This file was deleted.