-
Notifications
You must be signed in to change notification settings - Fork 558
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
feat(web-exception-instrumentation): Add instrumentation for web exceptions #2751
base: main
Are you sure you want to change the base?
feat(web-exception-instrumentation): Add instrumentation for web exceptions #2751
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2751 +/- ##
==========================================
- Coverage 91.53% 91.32% -0.21%
==========================================
Files 171 166 -5
Lines 8172 7861 -311
Branches 1660 1619 -41
==========================================
- Hits 7480 7179 -301
+ Misses 692 682 -10 🚀 New features to boost your workflow:
|
name: 'exception', | ||
data: { ...errorAttributes, ...customAttributes }, | ||
severityNumber: SeverityNumber.ERROR, | ||
timestamp: 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.
you should probably avoid Date
as it is less reliable than the performance api. Check https://github.com/open-telemetry/opentelemetry-js/blob/e947bd93aed7567eff48244ada983c756a7136f1/packages/opentelemetry-core/src/common/time.ts#L48-L59
: {}; | ||
|
||
eventLogger.emit({ | ||
name: 'exception', |
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.
Event names should be namespaced so just exception
doesn't actually match the semantic conventions.
Please work with @Karlie-777 and her PR around defining this exception open-telemetry/semantic-conventions#1942. I agree that using the 3 top level attributes makes sense for these and I've left some comments in the link PR as well.
There are a few other properties that we should also be setting (if possible), which does mean attempting to parse out the exception on the client.
|
||
eventLogger.emit({ | ||
name: 'exception', | ||
data: { ...errorAttributes, ...customAttributes }, |
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.
We should not be including the fully qualified "named" attributes in the payload (data), they should just be passed as attributes (or if we are not using the top-level attributes then they should not be prefixed by "exception.")
[ATTR_EXCEPTION_STACKTRACE]: error.stack, | ||
}; | ||
|
||
const eventLogger = events.getEventLogger( |
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.
We should also be including the "parsed" filename as well as the current url (hosting page), I also left a comment in the related event PR that this should be part of the client exception
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.
Note: if we end up using the url.full
then to comply with this PR it MUST be redacted and I don't believe that the JS repo currently has any "helpers" to construct a redacted url.full
.
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.
Additional comment, while it would be "nice" to just say that the URL is in the "resources" for SPA's it really needs to be mutable which resources can't currently be 😢
Which problem is this PR solving?
Currently, there's no standardized way to capture and monitor unhandled exceptions and promise rejections in web applications using OpenTelemetry. This makes it difficult for developers to:
Short description of the changes
Open questions
api
andapi-logs
package, is that okay or should they be redefined?