all repos — homestead @ 4ce11708c4a8cec453c80ffd9a11f1dcb00221b0

Code for my website

Just send one transaction to Sentry

Alan Pearce
commit

4ce11708c4a8cec453c80ffd9a11f1dcb00221b0

parent

c54bf87f151ba5df64db8db31c13c86c9cbe64d8

1 file changed, 6 insertions(+), 17 deletions(-)

jump to
M src/index.tssrc/index.ts
@@ -144,10 +144,6 @@ "http.method": request.method,
"http.user_agent": request.headers.get("user-agent"), }, }); - const span = transaction.startChild({ - op: "http.server", - description: `${request.method} ${pathname}`, - }); try { const file = files.get(pathname); metrics.requests.inc({ path: pathname });
@@ -157,7 +153,6 @@ parseIfModifiedSinceHeader(
request.headers.get("if-modified-since"), ) >= file?.mtime.getTime() ) { - span.setHttpStatus(304); metrics.requests.inc({ method: request.method, path: pathname,
@@ -175,9 +170,8 @@ const encodings = (request.headers.get("accept-encoding") || "")
.split(",") .map((x) => x.trim().toLowerCase()); if (encodings.includes("br") && files.has(file.relPath + ".br")) { - span.setTag("http.encoding", "br"); - span.setHttpStatus(200); transaction.setHttpStatus(200); + transaction.setTag("http.content-encoding", "br"); return serveFile(files.get(file.relPath + ".br"), 200, { "content-encoding": "br", "content-type": file.type,
@@ -186,9 +180,8 @@ } else if (
encodings.includes("zstd") && files.has(file.relPath + ".zst") ) { - span.setTag("http.encoding", "zstd"); - span.setHttpStatus(200); transaction.setHttpStatus(200); + transaction.setTag("http.content-encoding", "zstd"); return serveFile(files.get(file.relPath + ".zst"), 200, { "content-encoding": "zstd", "content-type": file.type,
@@ -197,17 +190,15 @@ } else if (
encodings.includes("gzip") && files.has(file.relPath + ".gz") ) { - span.setTag("http.encoding", "gzip"); - span.setHttpStatus(200); transaction.setHttpStatus(200); + transaction.setTag("http.content-encoding", "gzip"); return serveFile(files.get(file.relPath + ".gz"), 200, { "content-encoding": "gzip", "content-type": file.type, }); } - span.setTag("http.encoding", "identity"); - span.setHttpStatus(200); transaction.setHttpStatus(200); + transaction.setTag("http.content-encoding", "identity"); return serveFile(file); } else { metrics.requests.inc({
@@ -215,13 +206,12 @@ method: request.method,
path: pathname, status_code: 404, }); - span.setTag("http.encoding", "identity"); - span.setHttpStatus(404); transaction.setHttpStatus(404); + transaction.setTag("http.content-encoding", "identity"); return serveFile(files.get("/404.html"), 404); } } catch (error) { - span.setHttpStatus(503); + transaction.setTag("http.content-encoding", "identity"); transaction.setHttpStatus(503); metrics.requests.inc({ method: request.method,
@@ -233,7 +223,6 @@ return new Response("Something went wrong", { status: 503 });
} finally { const seconds = endTimer(); metrics.requestDuration.observe(seconds); - span.finish(); transaction.finish(); } },