diff options
-rw-r--r-- | src/index.ts | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/src/index.ts b/src/index.ts index 216dda1..450fe8f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -144,10 +144,6 @@ const server = Bun.serve({ "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 @@ const server = Bun.serve({ 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 server = Bun.serve({ .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 @@ const server = Bun.serve({ 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 @@ const server = Bun.serve({ 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 @@ const server = Bun.serve({ 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 @@ const server = Bun.serve({ } finally { const seconds = endTimer(); metrics.requestDuration.observe(seconds); - span.finish(); transaction.finish(); } }, |