Closed mderriey closed 6 months ago
@mderriey I'll take a look into this one further. Thank you for the investigation!
@mderriey PR above should resolve this issue.
@mderriey Closing this issue as we're waiting for an OpenTelemetry release. Please let me know if there are any follow ups to this issue and we can reopen. Thank you!
Hi there 👋
What
We're experiencing a behavior where some errors are not logged properly when using the OTel-based beta package.
We tracked this down to my previous PR that attempted to fix the case where objects were serialized as
[object Object]
.Why
The issue with the naïve approach of serializing as JSON is that it works for enumerable properties only.
Most native
Error
types have non-enumerable properties only:Some libraries, like axios, define custom error types with either enumerable properties or a
toJSON
function that is invoked byJSON.stringify
, which explains why the issue depends on which type of error is logged:How
It seems like a common issue in the JavaScript world, and it sounds like
Error
s would need to be special-cased when transforming a telemetry item into aLogRecord
. Existing npm packages like serialize-error go to great length to detect errors and destructure them; I'm not sure what the project policy is when it comes to third-party libraries, and this one in particular is an ES module which I had trouble using in my current TypeScript project configured to output CommonJS code.Thanks let me know if you need more information.