Skip to content

Commit b4fd717

Browse files
authored
fix: reset span name and http.route in static file middleware (#2856)
1 parent 1495099 commit b4fd717

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/middlewares/static_files.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { MiddlewareFn } from "./mod.ts";
44
import { ASSET_CACHE_BUST_KEY } from "../runtime/shared_internal.tsx";
55
import { BUILD_ID } from "../runtime/build_id.ts";
66
import { getBuildCache } from "../context.ts";
7-
import { tracer } from "../otel.ts";
7+
import { trace, tracer } from "../otel.ts";
88

99
/**
1010
* Fresh middleware to enable file-system based routing.
@@ -41,6 +41,12 @@ export function staticFiles<T>(): MiddlewareFn<T> {
4141
return new Response("Method Not Allowed", { status: 405 });
4242
}
4343

44+
const parentSpan = trace.getActiveSpan();
45+
if (parentSpan) {
46+
parentSpan.updateName(`${req.method} /*`);
47+
parentSpan.setAttribute("http.route", "/*");
48+
}
49+
4450
const span = tracer.startSpan("static file", {
4551
attributes: { "fresh.span_type": "static_file" },
4652
startTime,

src/otel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ import denoJson from "../deno.json" with { type: "json" };
44
export const CURRENT_FRESH_VERSION = denoJson.version;
55

66
export const tracer = trace.getTracer("fresh", CURRENT_FRESH_VERSION);
7+
export { trace };

0 commit comments

Comments
 (0)