-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(aws): Add support for automatic wrapping in ESM #17407
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
base: develop
Are you sure you want to change the base?
Conversation
responseHook(_span, { err }) { | ||
if (err) { | ||
captureException(err, scope => markEventUnhandled(scope, 'auto.function.aws-serverless.otel')); | ||
} | ||
}, |
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.
capturing errors here ensures that they're connected to the span correctly
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.
moved init code to separate file to avoid circular dependency
size-limit report 📦
|
return new Promise((resolve, reject) => plugin._endSpan(span, err, () => reject(err))); | ||
}, | ||
); | ||
} |
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.
Bug: Lambda Error Duplication in Sentry
Duplicate error events occur when Lambda handlers throw exceptions or return rejected promises. The vendored OpenTelemetry instrumentation's responseHook
captures the exception, which is then re-thrown and subsequently captured again by the wrapHandler
that wraps the patched handler. This leads to two identical error events in Sentry, with mechanism types 'auto.function.aws-serverless.otel' (from responseHook
) and 'auto.function.aws-serverless.handler' (from wrapHandler
).
Additional Locations (2)
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.
true, I guess in theory we could remove the catch block. But since errors are deduped anyway, we can also keep it just to be sure
This allows code-less setup for Lambda functions running in ESM (and thus the aws-serverless SDK in general) by vendoring the OpenTelemetry AwsLambda instrumentation and wrapping the patched handler with Sentry's
wrapHandler
.