Skip to content
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

Merged
merged 5 commits into from
Apr 23, 2020

Conversation

bobheadxi
Copy link
Contributor

This PR adds a keys option to provide custom keys programatically, and as part of the change allows users to set trace

Checklist

  • run npm run test
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message and code follows Code Of Conduct

Copy link
Owner

@ovhemert ovhemert left a 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 .

Comment on lines 26 to 29
const defaultKeys = {
httpRequest: 'httpRequest',
trace: 'trace'
}
Copy link
Owner

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.

Copy link
Contributor Author

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

Comment on lines +61 to +62
trace: _getKey(log, data, 'trace', keys),
httpRequest: _getKey(log, data, 'httpRequest', keys)
Copy link
Owner

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

Copy link
Contributor Author

@bobheadxi bobheadxi Apr 10, 2020

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

@ovhemert ovhemert added the enhancement New feature or request label Feb 10, 2020
@stale
Copy link

stale bot commented Apr 10, 2020

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.

@stale stale bot added the wontfix This will not be worked on label Apr 10, 2020
@stale stale bot removed the wontfix This will not be worked on label Apr 10, 2020
@bobheadxi
Copy link
Contributor Author

@ovhemert I've added some documentation + CLI support in 11f4923

@bobheadxi bobheadxi requested a review from ovhemert April 10, 2020 23:30
Copy link
Owner

@ovhemert ovhemert left a 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, [])
Copy link
Owner

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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

image

@ovhemert ovhemert merged commit 2bd0615 into ovhemert:master Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants