Skip to content

Commit 7921488

Browse files
authored
fix: report placeholder in prom metrics for invalid request paths (#1867)
* fix: report placeholder in prom metrics for invalid request paths * chore: pr feedback
1 parent b7ecefe commit 7921488

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/api/init.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,16 @@ export async function startApiServer(opts: {
110110
// Get the url pathname without a query string or fragment
111111
// (note base url doesn't matter, but required by URL constructor)
112112
try {
113-
let pathTemplate = new URL(path, 'http://x').pathname;
113+
const pathTemplate = new URL(path, 'http://x').pathname;
114114
// Match request url to the Express route, e.g.:
115115
// `/extended/v1/address/ST26DR4VGV507V1RZ1JNM7NN4K3DTGX810S62SBBR/stx` to
116116
// `/extended/v1/address/:stx_address/stx`
117117
for (const pathRegex of routes) {
118118
if (pathRegex.regexp.test(pathTemplate)) {
119-
pathTemplate = pathRegex.path;
120-
break;
119+
return pathRegex.path;
121120
}
122121
}
123-
return pathTemplate;
122+
return '<invalid_path>';
124123
} catch (error) {
125124
logger.warn(`Warning: ${error}`);
126125
return path;

0 commit comments

Comments
 (0)