customProps always logs duplicate keys
See original GitHub issuecustomProps always logs duplicate keys.
I am working with google cloud logging and it doesn’t play nicely with the duplicate keys:
customProps(req) {
// adds a custom object to all http logs that stackdriver
// uses to make logs more informative and visible at a glance
// see: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#httprequest
// for the details of the structured log messages
return {
httpRequest: {
requestMethod: req.method,
requestUrl: req.url,
userAgent: req.headers['user-agent'],
remoteIp:
req.headers['x-forwarded-for']?.split(',').shift() ||
req.socket?.remoteAddress,
},
};
},
For instance:
custom props cause the following log:
"{ "httpRequest": {"method":"GET"},"httpRequest": {"method":"GET"}}"
ends up in stackdriver/google cloud logging looking like:
{httpRequest: { method: 'GETGET' }}
related to https://github.com/pinojs/pino-http/pull/197
Issue Analytics
- State:
- Created a year ago
- Reactions:7
- Comments:22 (7 by maintainers)
Top Results From Across the Web
Template loop gives duplicate keys warning - Stack Overflow
Without unique information from the outer loop, the inner loop key will use the same set every time, so you end up with...
Read more >Duplicate key name message during Sterling B2B Integrator ...
Problem. When starting Sterling B2B Integrator, similar messages as below are logged to the console: [Manager] getProperties(): Duplicate key ...
Read more >Megalinks search engine - Spendy Market
MEGA provides free cloud storage with convenient and powerful always-on privacy. . ext. ... Log In Sign Up. me inurl:f/megalinks search terms. aka...
Read more >gta 5 props list
The largest collection of vehicle customizations and custom props for GTA V. ... GTA 5 Cheats Xbox Series X. Craft, cooperation and team...
Read more >All About "Do Not Duplicate" Keys - Door Locks Direct
Before buying any keyed locks, locksmiths always recommend that you check out the company's key duplication policy. If your locks are less ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Your usecase is a bit far from mine.
Would you like to send a Pull Request to address this issue? Remember to add unit tests.
This seems to work: