Skip to content

Commit

Permalink
fix: report placeholder in prom metrics for invalid request paths (#1867
Browse files Browse the repository at this point in the history
)

* fix: report placeholder in prom metrics for invalid request paths

* chore: pr feedback
  • Loading branch information
zone117x authored Feb 19, 2024
1 parent b7ecefe commit 7921488
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/api/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,16 @@ export async function startApiServer(opts: {
// Get the url pathname without a query string or fragment
// (note base url doesn't matter, but required by URL constructor)
try {
let pathTemplate = new URL(path, 'http://x').pathname;
const pathTemplate = new URL(path, 'http://x').pathname;
// Match request url to the Express route, e.g.:
// `/extended/v1/address/ST26DR4VGV507V1RZ1JNM7NN4K3DTGX810S62SBBR/stx` to
// `/extended/v1/address/:stx_address/stx`
for (const pathRegex of routes) {
if (pathRegex.regexp.test(pathTemplate)) {
pathTemplate = pathRegex.path;
break;
return pathRegex.path;
}
}
return pathTemplate;
return '<invalid_path>';
} catch (error) {
logger.warn(`Warning: ${error}`);
return path;
Expand Down

0 comments on commit 7921488

Please sign in to comment.