-
Notifications
You must be signed in to change notification settings - Fork 20
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
fix(keystone): INFRA-296 move gql related logging to pino auto-loggin… #4727
Conversation
Quality Gate passedIssues Measures |
@@ -1,6 +1,7 @@ | |||
const serializers = require('pino-std-serializers') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should it in package.json of keystone package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I'll do it right here
@@ -14,6 +15,12 @@ function getKeystonePinoOptions () { | |||
customProps: (req, res) => { | |||
return getReqLoggerContext(req) | |||
}, | |||
serializers: { | |||
res: (res) => { | |||
const errors = res.raw.req.errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be wrapped with get or optional chain in case of no errors or smth like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, sounds reasonable
serializers: { | ||
res: (res) => { | ||
const errors = res.raw.req.errors | ||
return { gqlErrors: errors, ...serializers.req(res) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, is it correct behaviour? (You're overriding serializers.res
, but using .req
here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's correct. It was done for security reasons (hide body of the logged response)
@@ -35,7 +49,7 @@ function getReqLoggerContext (req) { | |||
} | |||
} | |||
|
|||
return { reqId, sessionId, user, ip, fingerprint, complexity } | |||
return omitBy({ reqId, sessionId, user, ip, fingerprint, complexity, operationName, variables, query, operationId }, isNil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is omitting previously existing properties on object safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What did you mean? That op is just filtering out empty values of the resulting log output
…g context