elastic-apm-utils
Advanced tools
Comparing version 1.1.0 to 2.0.0
{ | ||
"name": "elastic-apm-utils", | ||
"description": "Utilities for Elastic APM", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"github": "https://github.com/MartinKolarik/elastic-apm-utils/", | ||
"main": "./src/index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"fast-url-parser": "^1.1.3", | ||
"lodash": "^4.17.10" | ||
"lodash": "^4.17.11" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^4.19.1" | ||
"@martin-kolarik/eslint-config": "^1.0.5", | ||
"eslint": "^5.9.0", | ||
"eslint-plugin-chai-expect": "^2.0.1", | ||
"eslint-plugin-html": "^5.0.0", | ||
"eslint-plugin-node": "^8.0.0", | ||
"eslint-plugin-promise": "^4.0.1" | ||
}, | ||
@@ -19,3 +25,2 @@ "author": { | ||
}, | ||
"license": "MIT", | ||
"repository": { | ||
@@ -25,2 +30,6 @@ "type": "git", | ||
}, | ||
"scripts": { | ||
"lint": "eslint src", | ||
"test": "npm run lint" | ||
}, | ||
"bugs": { | ||
@@ -27,0 +36,0 @@ "url": "https://github.com/MartinKolarik/elastic-apm-utils/issues" |
@@ -5,47 +5,39 @@ const _ = require('lodash'); | ||
module.exports.apm = { | ||
filter ({ filterNotSampled = true, keepRequest = [ 'referer', 'user-agent' ], keepResponse = [], keepSocket = [] } = {}) { | ||
transactionFilter ({ filterNotSampled = true, keepRequest = [ 'referer', 'user-agent' ], keepResponse = [], keepSocket = [] } = {}) { | ||
return (payload) => { | ||
if (!Array.isArray(payload.transactions)) { | ||
return payload; | ||
if (filterNotSampled && !payload.sampled) { | ||
return false; | ||
} | ||
if (filterNotSampled) { | ||
payload.transactions = payload.transactions.filter(transaction => transaction.sampled); | ||
if (!payload.context) { | ||
return payload; | ||
} | ||
payload.transactions = payload.transactions.map((transaction) => { | ||
if (!transaction.context) { | ||
return transaction; | ||
} | ||
let { request, response } = payload.context; | ||
let { request, response } = transaction.context; | ||
if (request) { | ||
if (request.headers) { | ||
if (keepRequest.length) { | ||
request.headers = _.pick(request.headers, keepRequest); | ||
} else { | ||
delete request.headers; | ||
} | ||
if (request) { | ||
if (request.headers) { | ||
if (keepRequest.length) { | ||
request.headers = _.pick(request.headers, keepRequest); | ||
} else { | ||
delete request.headers; | ||
} | ||
if (request.socket) { | ||
if (keepSocket.length) { | ||
request.socket = _.pick(request.socket, keepSocket); | ||
} else { | ||
delete request.socket; | ||
} | ||
} | ||
} | ||
if (response && response.headers) { | ||
if (keepResponse.length) { | ||
response.headers = _.pick(response.headers, keepResponse); | ||
if (request.socket) { | ||
if (keepSocket.length) { | ||
request.socket = _.pick(request.socket, keepSocket); | ||
} else { | ||
delete response.headers; | ||
delete request.socket; | ||
} | ||
} | ||
} | ||
return transaction; | ||
}); | ||
if (response && response.headers) { | ||
if (keepResponse.length) { | ||
response.headers = _.pick(response.headers, keepResponse); | ||
} else { | ||
delete response.headers; | ||
} | ||
} | ||
@@ -52,0 +44,0 @@ return payload; |
6300
6
90
Updatedlodash@^4.17.11