Errors are not serialized by batchLogRecordProcessor #30205
Labels
Client
This issue points to a problem in the data-plane of the library.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
Monitor
Monitor, Monitor Ingestion, Monitor Query
needs-team-attention
Workflow: This issue needs attention from Azure service team or SDK team
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
@azure/[email protected]
for the project I'm working on.My problem is that logRecord attributes that are
instanceof Error
are not serialized in a way that preserves themessage
andstack
props.JSON.stringify(new Error('hello'))
produces
{}
JSON.stringify
is used without a replacer that can enumerate themessage
andstack
props of an Error, because they are not enumerable (because JS).https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/monitor/monitor-opentelemetry/src/logs/batchLogRecordProcessor.ts#L35
In the patch below we are importing our own replacer with the very simple structure which simply spreads the
message
,stack
and other props of the error:https://github.com/MakerXStudio/node-winston/blob/main/src/serialize-error.ts
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: