-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
add support for custom http request key, trace #54
Conversation
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.
Looks like a nice addition. Please see my comments.
Could you also add some docs for this to /docs/CLI.md
and /docs/API.md
?
Should also be possible to specify keys from CLI .
src/stackdriver.js
Outdated
const defaultKeys = { | ||
httpRequest: 'httpRequest', | ||
trace: 'trace' | ||
} |
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.
Can you make the props of defaultKeys optional like:
const defaultKeys = { httpRequest: 'httpRequest' }
and then when adding them to entry.meta...
loop through keys to see if any exist like Object.keys
This way we can keep ik backwards compatible and not add anything extra if not specifically asked for.
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 be resolved in 2352d3d , I've removed trace
from the defaults
trace: _getKey(log, data, 'trace', keys), | ||
httpRequest: _getKey(log, data, 'httpRequest', keys) |
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.
add these dynamically by looking at specified keys
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 is currently just set to undefined
if key is not present, which should achieve the same behaviour - I've improved this and added additional tests in 2352d3d as well
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
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.
Looks good. Please see my comments.
// main cli logic | ||
function main () { | ||
program | ||
.version(pkg.version) | ||
.option('-c, --credentials <credentials>', 'The file path of the JSON file that contains your service account key') | ||
.option('-p, --project <project>', 'Your Google Cloud Platform project ID') | ||
.action(({ credentials, project }) => { | ||
.option('-k, --key <key:customKey>', 'Customize additional data to include in log metadata', collect, []) |
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.
Could you add a test for the new option so we'll have 100% test coverage again?
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.
Shouldn't it be covered by this test? https://github.com/ovhemert/pino-stackdriver/pull/54/files#diff-da8fe3f2391da380ddef00afcc0f93f0R54
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.
Ah I see - I've added an additional error case in 776b6e2
This PR adds a
keys
option to provide custom keys programatically, and as part of the change allows users to settrace
Checklist
npm run test