-
Notifications
You must be signed in to change notification settings - Fork 423
Closed
Description
Description
if the logger sends just object with message field, it is successfully logged through pinohttp into console, however the message is not present in forwarded log in newrelic
Expected Behavior
Pino log should be in newrelic should be equal to the log in console (containing message field)
Steps to Reproduce
newrelic.js:
exports.config = {
app_name: 'Test newrelic pino',
license_key: 'REDACTED',
application_logging: {
forwarding: {
enabled: true,
max_samples_stored: 10000,
},
},
};
index.js
require('newrelic');
const express = require('express');
const logger = require('pino-http');
const app = express();
app.use(logger());
app.get('/', (req, res) => {
req.log.info({
message: 'Test message',
message2: 'foo bar',
});
res.end('hello world')
})
app.listen(3000)
then run following CURL:
curl --request GET \
--url http://localhost:3000/ \
--header 'User-Agent: insomnia/10.0.0'
as result of
req.log.info({
message: 'Test message',
message2: 'foo bar',
});
- console will contain following log:
{"level":30,"time":1726833856289,"pid":2225,"hostname":"REDACTED","req":{"id":4,"method":"GET","url":"/","query":{},"params":{},"headers":{"host":"localhost:3000","cookie":"x-ms-gateway-slice=estsfd; stsservicecookie=estsfd","user-agent":"insomnia/10.0.0","accept":"*/*"},"remoteAddress":"::ffff:127.0.0.1","remotePort":58881},"res":{"statusCode":200,"headers":{"x-powered-by":"Express"}},"responseTime":2,"msg":"request completed"}
but in newrelic the message is not present:
{
"entity.guid": "REDACTED",
"entity.guids": "REDACTED",
"entity.name": "REDACTED",
"entity.type": "SERVICE",
"hostname": "REDACTED",
"level": "info",
"message2": "foo bar",
"newrelic.source": "logs.APM",
"pid": 2225,
"req.headers.accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"req.headers.accept-encoding": "gzip, deflate, br, zstd",
"req.headers.accept-language": "sk-SK,sk;q=0.9,cs-CZ;q=0.8,cs;q=0.7,en-US;q=0.6,en;q=0.5",
"req.headers.cache-control": "max-age=0",
"req.headers.connection": "keep-alive",
"req.headers.cookie": "REDACTED",
"req.headers.dnt": "1",
"req.headers.host": "localhost:3000",
"req.headers.sec-ch-ua": "\"Google Chrome\";v=\"129\", \"Not=A?Brand\";v=\"8\", \"Chromium\";v=\"129\"",
"req.headers.sec-ch-ua-mobile": "?0",
"req.headers.sec-ch-ua-platform": "\"macOS\"",
"req.headers.sec-fetch-dest": "document",
"req.headers.sec-fetch-mode": "navigate",
"req.headers.sec-fetch-site": "none",
"req.headers.sec-fetch-user": "?1",
"req.headers.upgrade-insecure-requests": "1",
"req.headers.user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
"req.id": 1,
"req.method": "GET",
"req.remoteAddress": "::1",
"req.remotePort": 58422,
"req.url": "/",
"span.id": "REDACTED",
"timestamp": 1726833780150,
"trace.id": "REDACTED"
}
as can be seen, log contains only "message2": "foo bar", and message is missing.
Your Environment
macOS Sonoma 14.6.1 (23G93)
node -v
v22.5.1
Additional context
It looks like somewhere in newrelic/instrumentation/pino - it is owerriding the message field in object using unexisting (optional) second parameter.
which results in empty message.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done: Issues recently completed