all repos — homestead @ e6694453139eb4e400079287ffbeec2aaa8cc620

Code for my website

Simplify metrics

Alan Pearce
commit

e6694453139eb4e400079287ffbeec2aaa8cc620

parent

6dc14f5f80ff0d99d959d98f539d7d2be0876f08

1 file changed, 1 insertion(+), 26 deletions(-)

jump to
M src/app.tssrc/app.ts
@@ -45,14 +45,7 @@ const metrics = {
requests: new prom.Counter({ name: "homestead_requests", help: "Number of requests by path, status code, and method", - labelNames: [ - "path", - "status_code", - "hostname", - "method", - "content_encoding", - "cache_basis", - ] as const, + labelNames: ["status_code", "content_encoding", "cache_basis"] as const, }), requestDuration: new prom.Histogram({ name: "homestead_request_duration_seconds",
@@ -162,10 +155,7 @@ config.redirect_other_hostnames &&
hostname !== expectedHostURL.host ) { metrics.requests.inc({ - method: request.method, - hostname, content_encoding: "identity", - path: pathname, status_code: (status = 301), }); return new Response("", {
@@ -186,10 +176,7 @@ request.headers.get("if-modified-since"),
) >= file?.mtime.getTime(); if (etagMatch || mtimeMatch) { metrics.requests.inc({ - method: request.method, - hostname, content_encoding: contentEncoding, - path: pathname, status_code: (status = 304), cache_basis: etagMatch ? "etag" : "mtime", });
@@ -211,9 +198,6 @@ }
status = 200; metrics.requests.inc({ - method: request.method, - hostname, - path: pathname, status_code: status, content_encoding: contentEncoding, });
@@ -231,9 +215,6 @@ } else {
if (files.has(pathname + "/")) { newpath = pathname + "/"; metrics.requests.inc({ - method: request.method, - hostname, - path: pathname, content_encoding: contentEncoding, status_code: (status = 302), });
@@ -244,9 +225,6 @@ });
} else if (files.has(pathname.replace(/index.html$/, ""))) { newpath = pathname.replace(/index.html$/, ""); metrics.requests.inc({ - method: request.method, - hostname, - path: newpath, content_encoding: contentEncoding, status_code: (status = 302), });
@@ -270,9 +248,6 @@ }
} } catch (error) { metrics.requests.inc({ - method: request.method, - hostname, - path: pathname, status_code: status, content_encoding: "identity", });