From d449cf9a9c53af439e23f46770d33b6c2f25a659 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sat, 16 Sep 2023 12:38:02 +0200 Subject: Tweak Sentry setup --- src/index.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/index.ts b/src/index.ts index 261bed4..6b7bdd3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -144,21 +144,14 @@ const server = Bun.serve({ name: pathname, op: "http.server", description: `${request.method} ${pathname}`, - data: { + tags: { url: request.url, "http.method": request.method, }, - tags: { - region: Bun.env.FLY_APP_REGION, - }, }); const span = transaction.startChild({ op: "http.server", description: `${request.method} ${pathname}`, - data: { - url: request.url, - "http.method": request.method, - }, }); try { const file = files.get(pathname); @@ -170,7 +163,8 @@ const server = Bun.serve({ ) >= file?.mtime.getTime() ) { metrics.requestsByStatus.inc({ status_code: 304 }); - span.setTag("http.status_code", 304); + span.setHttpStatus(304); + transaction.setHttpStatus(304); return new Response("", { status: 304, headers: defaultHeaders }); } const encodings = (request.headers.get("accept-encoding") || "") @@ -178,7 +172,8 @@ const server = Bun.serve({ .map((x) => x.trim().toLowerCase()); if (encodings.includes("br") && files.has(file.relPath + ".br")) { span.setTag("http.encoding", "br"); - span.setTag("http.status_code", 200); + span.setHttpStatus(200); + transaction.setHttpStatus(200); return serveFile(files.get(file.relPath + ".br"), 200, { "content-encoding": "br", "content-type": file.type, @@ -188,7 +183,8 @@ const server = Bun.serve({ files.has(file.relPath + ".zst") ) { span.setTag("http.encoding", "zstd"); - span.setTag("http.status_code", 200); + span.setHttpStatus(200); + transaction.setHttpStatus(200); return serveFile(files.get(file.relPath + ".zst"), 200, { "content-encoding": "zstd", "content-type": file.type, @@ -198,23 +194,27 @@ const server = Bun.serve({ files.has(file.relPath + ".gz") ) { span.setTag("http.encoding", "gzip"); - span.setTag("http.status_code", 200); + span.setHttpStatus(200); + transaction.setHttpStatus(200); return serveFile(files.get(file.relPath + ".gz"), 200, { "content-encoding": "gzip", "content-type": file.type, }); } span.setTag("http.encoding", "identity"); - span.setTag("http.status_code", 200); + span.setHttpStatus(200); + transaction.setHttpStatus(200); return serveFile(file); } else { metrics.requestsByStatus.inc({ status_code: 404 }); span.setTag("http.encoding", "identity"); - span.setTag("http.status_code", 404); + span.setHttpStatus(404); + transaction.setHttpStatus(404); return serveFile(files.get("/404.html"), 404); } } catch (error) { - span.setTag("http.status_code", 503); + span.setHttpStatus(503); + transaction.setHttpStatus(503); metrics.requestsByStatus.inc({ status_code: 503 }); Sentry.captureException(error); return new Response("Something went wrong", { status: 503 }); -- cgit 1.4.1