-
Notifications
You must be signed in to change notification settings - Fork 35
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
[SVLS-4699] Detect exceptions raised outside of the handler #533
[SVLS-4699] Detect exceptions raised outside of the handler #533
Conversation
c96415d
to
a0c2e24
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #533 +/- ##
==========================================
+ Coverage 81.75% 82.10% +0.35%
==========================================
Files 54 56 +2
Lines 2209 2286 +77
Branches 515 529 +14
==========================================
+ Hits 1806 1877 +71
- Misses 337 344 +7
+ Partials 66 65 -1 ☔ View full report in Codecov by Sentry. |
ef5ba7e
to
e0259a0
Compare
…d outside of the handler function
375112c
to
02e9ae7
Compare
5a9d85c
to
050662c
Compare
src/handler.cjs
Outdated
try { | ||
exports.handler = datadog(loadSync(taskRootEnv, handlerEnv), { traceExtractor }); | ||
} catch (error) { | ||
emitTelemetryOnErrorOutsideHandler(error, handlerEnv, Date.now()); |
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.
I might be wrong but is this fire and forget
way of invoking the async method? I'm just wondering if we need to add a.catch(error => { // something like logDebug(error) });
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.
thanks! yes I think you're right, added
src/handler.mjs
Outdated
@@ -26,4 +33,12 @@ if (extractorEnv) { | |||
} | |||
} | |||
|
|||
export const handler = datadog(await load(taskRootEnv, handlerEnv), { traceExtractor }); | |||
let wrapped_handler; |
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.
nit: use camel case wrappedHandler
src/metrics/enhanced-metrics.ts
Outdated
if (context.invokedFunctionArn) { | ||
arnTags = parseTagsFromARN(context.invokedFunctionArn, context.functionVersion); | ||
} | ||
tags = [...arnTags, `memorysize:${context.memoryLimitInMB}`]; |
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.
Does js have an append
-like function? so we don't have to do the extra allocation.
c04d253
to
f14e402
Compare
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.
Left some comments.
src/index.ts
Outdated
const metricsListener = new MetricsListener(new KMSService(), config); | ||
await metricsListener.onStartInvocation(undefined); | ||
if (config.enhancedMetrics) { | ||
incrementErrorsMetric(metricsListener); | ||
} | ||
await metricsListener.onCompleteInvocation(); |
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.
Why don't we just lazy load everything inside of the condition?
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.
Good idea! Updated
What does this PR do?
This PR adds telemetry for exceptions that occur outside of the handler function.
When an exception occurs outside of the handler function:
aws.lambda.enhanced.errors
is emittedMotivation
Testing Guidelines
and one like this for testing "mjs" handler:
aws.lambda.enhanced.errors
emitted (graph)Additional Notes
Types of Changes
Check all that apply