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(amazonq): attach stack trace in onCodeGeneration failures #6293

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

siakmun-aws
Copy link
Contributor

Problem

To further find issues in onCodeGeneration, need to attach stack trace when sending metrics

Solution

Attach stack trace when sending metrics


  • 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.

@siakmun-aws siakmun-aws marked this pull request as ready for review December 27, 2024 00:03
@siakmun-aws siakmun-aws requested review from a team as code owners December 27, 2024 00:03
@siakmun-aws siakmun-aws force-pushed the siakmun/classify-exceptions branch from 912dfce to 3b41c98 Compare January 6, 2025 18:50
@siakmun-aws siakmun-aws force-pushed the siakmun/classify-exceptions branch from 3b41c98 to 33a1006 Compare January 23, 2025 20:09
Copy link
Contributor

@justinmk3 justinmk3 left a comment

Choose a reason for hiding this comment

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

This is lacking an acceptable explanation of what the purpose is, and how it works. Did you test this with a production webpack'd build? Nodejs stacktraces in the production build are usually obfuscated.

The docstring of the function does not give useful insights.

The function is non-trivial, and has no test coverage.

Assuming the function works, it belongs in a core util module, not randomly in the middle of a feature module.

@siakmun-aws
Copy link
Contributor Author

This is lacking an acceptable explanation of what the purpose is, and how it works. Did you test this with a production webpack'd build? Nodejs stacktraces in the production build are usually obfuscated.

The docstring of the function does not give useful insights.

The function is non-trivial, and has no test coverage.

Assuming the function works, it belongs in a core util module, not randomly in the middle of a feature module.

Here is some background on the purpose of this PR. The previous (main branch) client has been able to send telemetry in the event of code generation failure. However, any uncaught errors, either toolkit or runtime error etc., will only result in sending a "Fault" telemetry. We want to be able to diagnose such errors, and therefore the stack trace is needed. TS obfuscation is expected since non-toolkit errors such as runtime errors are not obfuscated. Uncaught toolkit error names are obfuscated, but through the function names (not obfuscated) in the stack trace combined with the code line number and toolkit version, the cause can still be identified.

Docstring: modified since last commit to give more details
Test: added
File place: changed to shared/error.ts

@siakmun-aws siakmun-aws force-pushed the siakmun/classify-exceptions branch from 49425ff to 977af16 Compare January 28, 2025 22:10
@@ -368,6 +368,57 @@ export function getTelemetryResult(error: unknown | undefined): Result {
return 'Failed'
}

export class SafeMessageToolkitError extends ToolkitError {
public constructor(message: string, info: ErrorInformation = {}) {
super(message, info)
Copy link
Contributor

Choose a reason for hiding this comment

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

what is going on here? why was this new base class introduced? what is the intended meaning of "safe message" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Safe message means the error message is safe to send to telemetry (no critical information). This was introduced to allow error classes which extends it can be sent to telemetry with its error message.
But this PR is not ready yet, so I will draft it for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

That doesn't sound like the right direction. We already have scrubNames

export function scrubNames(s: string, username?: string) {

which removes PII from strings. And that is used by getTelemetryReasonDesc, which already is used automatically.

Adding new, special classes is not the right way to approach this.

@siakmun-aws siakmun-aws marked this pull request as draft January 29, 2025 18:33
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