Skip to content

Commit

Permalink
[express] Address PR feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
alloy committed Sep 5, 2018
1 parent d8d2761 commit 4f2558b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Each integration also has its own list of default tags. These tags get automatic
|------------------|---------------------------|----------------------------------------|
| 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. |
| headers | `[]` | An array of headers to include in the span metadata. |

<h3 id="graphql">graphql</h3>

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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()) : []
const headersToRecord = Array.isArray(config.headers) ? config.headers.map(key => key.toLowerCase()) : []

const validateStatus = typeof config.validateStatus === 'function'
? config.validateStatus
Expand Down Expand Up @@ -48,7 +48,7 @@ function createWrapMethod (tracer, config) {
span.setTag(Tags.ERROR, true)
}

recordHeaders.forEach(key => {
headersToRecord.forEach(key => {
const value = req.headers[key]
if (value) {
span.setTag(`http.headers.${key}`, value)
Expand Down
2 changes: 1 addition & 1 deletion test/plugins/express.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ describe('Plugin', () => {
config = {
service: 'custom',
validateStatus: code => code < 400,
recordHeaders: ['User-Agent']
headers: ['User-Agent']
}

return agent.load(plugin, 'express', config)
Expand Down

0 comments on commit 4f2558b

Please sign in to comment.