[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
| try { | ||
| exports.handler = datadog(loadSync(taskRootEnv, handlerEnv), { traceExtractor }); | ||
| } catch (error) { | ||
| emitTelemetryOnErrorOutsideHandler(error, handlerEnv, Date.now()); |
There was a problem hiding this comment.
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.
thanks! yes I think you're right, added
| } | ||
|
|
||
| export const handler = datadog(await load(taskRootEnv, handlerEnv), { traceExtractor }); | ||
| let wrapped_handler; |
There was a problem hiding this comment.
nit: use camel case wrappedHandler
| if (context.invokedFunctionArn) { | ||
| arnTags = parseTagsFromARN(context.invokedFunctionArn, context.functionVersion); | ||
| } | ||
| tags = [...arnTags, `memorysize:${context.memoryLimitInMB}`]; |
There was a problem hiding this comment.
Does js have an append-like function? so we don't have to do the extra allocation.
c04d253 to
f14e402
Compare
| 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.
Why don't we just lazy load everything inside of the condition?
There was a problem hiding this comment.
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.errorsis emittedMotivation
Testing Guidelines
and one like this for testing "mjs" handler:
aws.lambda.enhanced.errorsemitted (graph)Additional Notes
Types of Changes
Check all that apply