-
Notifications
You must be signed in to change notification settings - Fork 570
feat(web-exception-instrumentation): Add instrumentation for web exceptions #2751
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: 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 89.60% 89.60%
=======================================
Files 174 174
Lines 8450 8450
Branches 1660 1660
=======================================
Hits 7572 7572
Misses 878 878 🚀 New features to boost your workflow:
|
plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
: {}; | ||
|
||
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.
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.
Could we be consistent with the existing semantic conventions for span events (where the event name is "exception")? Or, do we need to define exception event for each separate domain (e.g. "browser.exception", "android.exception" etc.)?
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've changed it to exception
for now since we're not creating any client specific semantic conventions for errors yet. We can change it in the future if this pattern develops.
plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
[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 😢
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.
For now, since we're sticking with the existing semantic conventions instead of client specific ones I haven't included the parsed file name or URL. I think we can add the URL in a future PR and add some core helpers to do that separately.
a37abc4
to
f1816f9
Compare
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?