-
Notifications
You must be signed in to change notification settings - Fork 399
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
Unhandled error during JSON.parse #1744
Comments
@OlenaHryshko thanks for your report. We can provide some defensive code but this also appears to be a bug with pino because it cannot properly stringify an object that has a
|
@bizob2828 thanks for your response. |
@OlenaHryshko that has been released in 10.6.2 |
@bizob2828 thank you for the notification |
Description
Using newrelic to capture application logs + pino as a logger agent.
While logging using pino, it is possible to pass mergingObject to add more context to the log. In case key(s) of the mergingObject contains
"
symbol, it is not getting shielded. So, logged object is not a JSON string, but newrelic lib tries to parse it to a JSON object.NewRelic throws an error below:
Expected Behavior
Handle JSON.parse error.
In case it is not possible to parse JSON object from log string, save the whole log string as a message.
Troubleshooting or NR Diag results
As per comment in the code, newrelic calls pino asJson method. It returns invalid JSON string, which is getting passed into newrelic reformatLogLine method.
Steps to Reproduce
logger.info({'some"prop': {'details': true}})
.Code snippet:
This will result in the log below:
{"level":30,"time":1690897379299,"pid":41644,"hostname":"your-hostname","some"prop":{"details":true}}
After this newrelic will pick up the log, try to do JSON.parse and throw the error mentioned above.
Your Environment
Additional context
The text was updated successfully, but these errors were encountered: