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

[express] Add option to record HTTP headers. #266

Merged
merged 2 commits into from
Sep 5, 2018

Conversation

alloy
Copy link
Contributor

@alloy alloy commented Aug 30, 2018

In our case we have some clients of our GraphQL service that do not (yet) have any DD tracing, so in order to namespace GraphQL operations to specific clients I want to record their user-agent.

@alloy alloy force-pushed the express-capture-headers branch from 69fda45 to e4f2afd Compare August 30, 2018 18:23
Copy link
Member

@rochdev rochdev left a comment

Choose a reason for hiding this comment

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

Since this is a new functionality, can you rebase on v0.6.0?

docs/API.md Outdated

<h5 id="express-config">Configuration Options</h5>

| Option | Default | Description |
|------------------|---------------------------|----------------------------------------|
| service | *Service name of the app* | The service name for this integration. |
| validateStatus | `code => code < 500` | Callback function to determine if there was an error. It should take a status code as its only parameter and return `true` for success or `false` for errors. |
| recordHeaders | `undefined` | An array of headers to include in the span metadata. |
Copy link
Member

Choose a reason for hiding this comment

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

The default should be [].

@@ -9,6 +9,8 @@ const pathToRegExp = require('path-to-regexp')
const OPERATION_NAME = 'express.request'

function createWrapMethod (tracer, config) {
const recordHeaders = config.recordHeaders ? config.recordHeaders.map(key => key.toLowerCase()) : []
Copy link
Member

Choose a reason for hiding this comment

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

Make sure it's an array first to be safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I figured that an error here, early in the process, could help setup of the plugin. What would you want to happen if this is not an array?

Copy link
Member

Choose a reason for hiding this comment

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

The idea is to try and never crash, even if any user input is wrong. In any case where it would be interesting to know why something is not working, a log entry of the appropriate level should be created instead, which the user will be able to view in debug mode.

docs/API.md Outdated

<h5 id="express-config">Configuration Options</h5>

| Option | Default | Description |
|------------------|---------------------------|----------------------------------------|
| service | *Service name of the app* | The service name for this integration. |
| validateStatus | `code => code < 500` | Callback function to determine if there was an error. It should take a status code as its only parameter and return `true` for success or `false` for errors. |
| recordHeaders | `[]` | An array of headers to include in the span metadata. |
Copy link
Member

Choose a reason for hiding this comment

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

Me again, your favorite nitpicker :) I think simply headers would make more sense to avoid a verb since this is not a function nor a boolean value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hah. I appreciate it, naming is hard 👍

@rochdev
Copy link
Member

rochdev commented Sep 4, 2018

Also don't forget to rebase on v0.6.0 branch

@alloy
Copy link
Contributor Author

alloy commented Sep 4, 2018

Ohhh, I had previously thought you meant that master was in prep for v0.6.0. I see, I’ll rebase it on there instead 👍

@alloy alloy force-pushed the express-capture-headers branch from e5617ce to 4f2558b Compare September 5, 2018 08:17
@alloy alloy changed the base branch from master to v0.6.0 September 5, 2018 08:17
@alloy alloy force-pushed the express-capture-headers branch from 4f2558b to a5ec769 Compare September 5, 2018 08:19
@alloy
Copy link
Contributor Author

alloy commented Sep 5, 2018

Done 👍

@alloy alloy force-pushed the express-capture-headers branch from a5ec769 to e7bf780 Compare September 5, 2018 08:38
@rochdev rochdev merged commit 28fe671 into DataDog:v0.6.0 Sep 5, 2018
@rochdev rochdev added this to the 0.6.0 milestone Sep 5, 2018
@alloy alloy deleted the express-capture-headers branch September 5, 2018 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants