Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
feat: add the hostname and port to the request name if different from…
Browse files Browse the repository at this point in the history
… the target
  • Loading branch information
jeffhall4 authored and hassy committed May 2, 2023
1 parent 29e4e3a commit 82e38bb
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,17 @@ function MetricsByEndpoint(script, events) {
}

function metricsByEndpoint_afterResponse(req, res, userContext, events, done) {
// TODO: If hostname is not target, keep it.
const baseUrl = url.parse(req.url).path;
const targetUrl = userContext.vars.target && url.parse(userContext.vars.target);
const requestUrl = url.parse(req.url);

let baseUrl = '';
if (targetUrl && requestUrl.hostname && targetUrl.hostname !== requestUrl.hostname) {
baseUrl += requestUrl.hostname
}
if (targetUrl && requestUrl.port && targetUrl.port !== requestUrl.port) {
baseUrl += `:${requestUrl.port}`
}
baseUrl += requestUrl.path

let reqName = '';
if (useOnlyRequestNames && req.name) {
Expand Down

0 comments on commit 82e38bb

Please sign in to comment.