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 convertReqRes boolean option; make req/res conversion off by default #32

Closed
trentm opened this issue Jan 15, 2021 · 1 comment
Closed
Assignees
Labels
agent-nodejs Make available for APM Agents project planning.

Comments

@trentm
Copy link
Member

trentm commented Jan 15, 2021

The current version of the winston and pino ecs-logging formatters automatically handle logging of req, res, request, and response extra fields: converting them from HTTP request and response objects to ECS HTTP, URL, and User agent fields.

This ticket is proposing a BREAKING CHANGE to this while these packages are still in pre-1.x beta:

  1. Turn this off by default and provide a convertReqRes: true boolean option to turn it on.
  2. Only handle req and res as special.

My understanding is the main idea for specially handling HTTP request/response objects stems from:

The argument for making this configurable is to handle the case where a user wants to log req/res but not for an HTTP request or response. The main argument for turning off req/res handling by default is that the req/res handlers in pino and Bunyan are also off by default. As well, having the option to turn on an extra feature feels a little more discoverable... but one could go either way on that.

The argument for only supporting req / res and not request / response is the prevalent usage of just req / res in pino and Bunyan. All examples of logging in code docs for Node.js frameworks that I could find use the short "req" and "res". I would prefer to start these libraries without multiple ways to perform the same thing. If there is a strong use case brought up for them, a separate ticket could discuss re-adding them.

Exception: morgan

Morgan is explicitly "HTTP request logger middleware for node.js". It doesn't provide logging methods for the app developer to even pass in extra fields. It doesn't make sense to have the default @elastic/ecs-morgan-format not render request and response fields.

@trentm trentm self-assigned this Jan 15, 2021
@trentm trentm added the agent-nodejs Make available for APM Agents project planning. label Jan 15, 2021
trentm added a commit that referenced this issue Jan 15, 2021
BREAKING CHANGE: Require convertReqRes:true option to handle 'req' and 'res' meta keys.
Also no longer support handling 'request' and 'response' meta keys.

Refs: #32
trentm added a commit that referenced this issue Jan 18, 2021
BREAKING CHANGE: Require convertReqRes:true option to handle 'req' and 'res'
keys in the mergingObject, e.g. `log.info({req, res}, 'the message')`.
Also no longer support handling 'request' and 'response' keys.

Refs: #32
@trentm
Copy link
Member Author

trentm commented Jan 18, 2021

^^ Done for winston and pino, and morgan won't get the option (see "Exception" note).

These will be in the next release.

@trentm trentm closed this as completed Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-nodejs Make available for APM Agents project planning.
Projects
None yet
Development

No branches or pull requests

1 participant