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

Open
wants to merge 42 commits into
base: feature/amazonqLSP
Choose a base branch
from

Conversation

Hweinstock
Copy link
Contributor

@Hweinstock Hweinstock commented Jan 16, 2025

Problem

LSP downloading processes does not emit any telemetry.

Solution

Refactoring

  • separate verification from core downloading steps so that we can capture it as its own telemetry event.
  • Note: this refactor means that if all the downloaded content cannot be verified, no files will be written to disk.
  • Introduce abstraction of StageResolver to make telemetry instrumentation more natural.

Metric Behavior

Testing

  • adds basic tests for ManifestResolver in packages/core/src/test/shared/lsp/manifestResolver.test.ts.
  • adds basic tests for LanguageServerResolver in packages/core/src/test/shared/lsp/lspResolver.test.ts.
  • Currently LanguageServerResolver only supports mac, so its tests skip on non-mac platforms. There is a techdebt test to address this.

Future Work

  • Update logging messages to be LSP specific.

  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

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.

@justinmk3 justinmk3 changed the title telemetry(lsp): Integrate langauge server/manifest resolver telemetry telemetry(lsp): Integrate language server/manifest resolver telemetry Jan 17, 2025
@Hweinstock Hweinstock force-pushed the telemetry/setup branch 2 times, most recently from 94902b9 to 87913ca Compare January 17, 2025 16:07
Hweinstock added a commit to aws/aws-toolkit-common that referenced this pull request Jan 23, 2025
## Problem
Relevant PR: aws/aws-toolkit-vscode#6385

## Solution
- standardize the metrics across the toolkits. 
<!---
    REMINDER:
    - Read CONTRIBUTING.md first.
    - Add test coverage for your changes.
    - Link to related issues/commits.
    - Testing: how did you test your changes?
    - Screenshots if applicable
-->

## License

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

---------

Co-authored-by: Shruti Sinha <[email protected]>
@Hweinstock Hweinstock changed the title telemetry(lsp): Integrate language server/manifest resolver telemetry telemetry(lsp): Integrate language server/manifest resolver telemetry (WIP) Jan 23, 2025
@Hweinstock Hweinstock changed the title telemetry(lsp): Integrate language server/manifest resolver telemetry (WIP) telemetry(lsp): Integrate language server/manifest resolver telemetry Jan 28, 2025
@Hweinstock Hweinstock marked this pull request as ready for review January 28, 2025 16:31
@Hweinstock Hweinstock requested review from a team as code owners January 28, 2025 16:31
packages/core/package.nls.json Show resolved Hide resolved
await lspSetupStage('all', async () => {
const installResult = await new WorkspaceLSPResolver().resolve()
await lspSetupStage('launch', async () => activateLsp(context, installResult.resourcePaths))
getLogger().info('LspController: LSP activated')
Copy link
Contributor

Choose a reason for hiding this comment

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

Not necessarily an issue for this PR, but I think we should probably scope these messages to regular codewhisperer language server vs workspace context one

Copy link
Contributor Author

@Hweinstock Hweinstock Feb 3, 2025

Choose a reason for hiding this comment

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

Yeah, I think we could make use of the logging header here that references which LSP it is. Can do as a follow up.

await fs.delete(cacheDirectory, {
recursive: true,
})
const serverResolvers: StageResolver<LspResult>[] = [
Copy link
Contributor

Choose a reason for hiding this comment

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

not neccessarily a problem but just wanted to call it out for anyone reading -- this is where we will slightly deviate from eclipse/visual studios implementations. We can just do some things a bit simpler

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In what ways does this deviate from their implementations? Would it be easier if I modified the implementation to closer mirror those implementations?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just the structure of having resolvers. It's not a big deal. I just copied Visual Studios implementation and basically ported it to typescript. AFAIK Eclipse ported Visual Studio's implementation for this code to java. This is just a slight refactor of their work

if (!isMac) {
this.skip()
}
localStub.resolves(lspResult('cache'))
Copy link
Contributor

Choose a reason for hiding this comment

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

there are technically non stubbed versions of these tests in the integ or e2e folder btw. It might make sense to just add telemetry assertions there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where are these tests? I am having some trouble finding them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the telemetry to this test, and fixed an edge case with validate emitting when the fetch failed. There are definitely some paths not covered in the e2e tests so it might make sense to keep the other tests as well. However, I'm open to deleting them if you don't see value there.

Copy link
Contributor

Choose a reason for hiding this comment

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

What functionality is covered in this one thats not in those other ones?

@Hweinstock
Copy link
Contributor Author

Hweinstock commented Feb 4, 2025

/runIntegrationTests

@jpinkney-aws
Copy link
Contributor

Ah looks like the e2e tests are failing with the thing you mentioned in standup

@Hweinstock
Copy link
Contributor Author

Hweinstock commented Feb 4, 2025

Oh interesting. I suspect this might be something else since I stubbed the workspaceLSPInstaller. The remote manifest fetch fails on local, but works in CI the first time then fails. Not sure why, but appears to be fairly consistent. I'll adjust the tests and add a note that it doesn't work locally.

@@ -117,6 +121,86 @@ describe('AmazonQLSPInstaller', () => {
assert.ok(fallback.assetDirectory.startsWith(tempDir))
assert.deepStrictEqual(fallback.location, 'fallback')
assert.ok(semver.satisfies(fallback.version, supportedLspServerVersions))

// Exclude version numbers so that this test doesn't have to be updated on each update.
// Fetching manifest fails locally, but passes in CI. Therefore, this test will fail locally.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain more about this? The test will fail locally?

if (!isMac) {
this.skip()
}
localStub.resolves(lspResult('cache'))
Copy link
Contributor

Choose a reason for hiding this comment

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

What functionality is covered in this one thats not in those other ones?

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