-
Notifications
You must be signed in to change notification settings - Fork 359
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
Amazon Q Code Transform: Add telemetry helper functions for common API telemetry. #5044
base: master
Are you sure you want to change the base?
Conversation
Failures are unrelated to my changes: Unix failures
Windows failures
|
let uploadId = parameters.uploadId | ||
try { | ||
uploadId = (result as CreateUploadUrlResponse).uploadId | ||
} catch (_) { | ||
//noop | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try/catch is not necessary here. Just use .?
operator.
that also allows use of const
.
let uploadId = parameters.uploadId | |
try { | |
uploadId = (result as CreateUploadUrlResponse).uploadId | |
} catch (_) { | |
//noop | |
} | |
const uploadId = (result as CreateUploadUrlResponse)?.uploadId ?? parameters.uploadId |
try { | ||
requestId = (result as PromiseResult<CodeTransformAPIresponse, AWSError>).$response.requestId | ||
} catch (_) { | ||
// noop | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try/catch not necessary, and discouraged. use getRequestId
from errors.ts.
codeTransformRunTimeLatency: calculateTotalLatency(apiStartTime), | ||
codeTransformJobId: parameters.jobId, | ||
codeTransformTotalByteSize: parameters.uploadFileByteSize, | ||
codeTransformRequestId: requestId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a standard requestId
field already. any reason not to use it?
Glad to see this effort to reduce code duplication, but it's really unfortunate that gumby telemetry is designed this way. This could be avoided by wrapping your logic in aws-toolkit-vscode/packages/core/src/shared/telemetry/spans.ts Lines 151 to 164 in 93396cc
Unfortunately, because gumby has not modeled telemetry to represent actions, and instead has "latency" and "error" metrics, this doesn't quite fit semantically. |
Problem
codeTransform_logApiLatency
andcodeTransform_logApiError
metrics.codeTransform_logApiLatency
only emitted on success but not also on failureSolution
Add
TelemetryHelper
which offerscallApi
function that wraps an API call with relevant telemetry for CodeTransform APIs. Download / Upload calls are not supported as the structure of their responses differ.TelemetryHelper
is also a first step towards:License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.