@aspecto/core
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -12,2 +12,3 @@ "use strict"; | ||
const url_patterns_1 = require("../utils/url-patterns"); | ||
const report_cache_1 = __importDefault(require("../utils/report-cache")); | ||
let aspectoHttpClient; | ||
@@ -20,2 +21,4 @@ const cloneResponse = (res) => { | ||
}; | ||
const secondsInterval = 300; // 5 minutes | ||
const reportCache = new report_cache_1.default(secondsInterval); | ||
const newRequest = (oldRequest, protocol) => (options, callback = (_res) => { }) => { | ||
@@ -34,2 +37,6 @@ const startTime = Date.now(); | ||
var _a, _b, _c, _d; | ||
const host = (_d = (_c = (_b = (_a = res) === null || _a === void 0 ? void 0 : _a.connection) === null || _b === void 0 ? void 0 : _b._host, (_c !== null && _c !== void 0 ? _c : options.hostname)), (_d !== null && _d !== void 0 ? _d : options.host)); | ||
const reportCount = reportCache.getReportCount(host); | ||
if (reportCount <= 0) | ||
return; | ||
body = body.join(); | ||
@@ -46,3 +53,2 @@ try { | ||
catch (_f) { } | ||
const host = (_d = (_c = (_b = (_a = res) === null || _a === void 0 ? void 0 : _a.connection) === null || _b === void 0 ? void 0 : _b._host, (_c !== null && _c !== void 0 ? _c : options.hostname)), (_d !== null && _d !== void 0 ? _d : options.host)); | ||
const port = [443, 80].includes(res.connection.remotePort) ? null : res.connection.remotePort; | ||
@@ -73,2 +79,6 @@ const fullUrl = `${protocol}://${host}${port ? `:${port}` : ``}${options.path}`; | ||
route: { path: patterns.path }, | ||
intervalAggregation: { | ||
requestsInInterval: reportCount, | ||
secondsInterval, | ||
}, | ||
}; | ||
@@ -75,0 +85,0 @@ aspectoHttpClient.sendData(aspectoPayload); |
@@ -7,2 +7,6 @@ "use strict"; | ||
}; | ||
const isMongoId = (id) => { | ||
const re = /^[0-9a-fA-F]{24}$/i; | ||
return re.test(String(id)); | ||
}; | ||
exports.findPatterns = (url) => { | ||
@@ -17,3 +21,3 @@ let patternsFound = 0; | ||
.forEach((val) => { | ||
if (isUuid(val)) { | ||
if (isUuid(val) || isMongoId(val)) { | ||
const id = `param${patternsFound}`; | ||
@@ -20,0 +24,0 @@ patterns.params[id] = val; |
{ | ||
"name": "@aspecto/core", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Aspecto metric collector", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
76951
76
1205