diff --git a/src/middlewares/static_files.ts b/src/middlewares/static_files.ts index c4f08ec60ff..6e82a177de6 100644 --- a/src/middlewares/static_files.ts +++ b/src/middlewares/static_files.ts @@ -4,7 +4,7 @@ import type { MiddlewareFn } from "./mod.ts"; import { ASSET_CACHE_BUST_KEY } from "../runtime/shared_internal.tsx"; import { BUILD_ID } from "../runtime/build_id.ts"; import { getBuildCache } from "../context.ts"; -import { tracer } from "../otel.ts"; +import { trace, tracer } from "../otel.ts"; /** * Fresh middleware to enable file-system based routing. @@ -41,6 +41,12 @@ export function staticFiles(): MiddlewareFn { return new Response("Method Not Allowed", { status: 405 }); } + const parentSpan = trace.getActiveSpan(); + if (parentSpan) { + parentSpan.updateName(`${req.method} /*`); + parentSpan.setAttribute("http.route", "/*"); + } + const span = tracer.startSpan("static file", { attributes: { "fresh.span_type": "static_file" }, startTime, diff --git a/src/otel.ts b/src/otel.ts index 45c5633efda..6c0d7a23e78 100644 --- a/src/otel.ts +++ b/src/otel.ts @@ -4,3 +4,4 @@ import denoJson from "../deno.json" with { type: "json" }; export const CURRENT_FRESH_VERSION = denoJson.version; export const tracer = trace.getTracer("fresh", CURRENT_FRESH_VERSION); +export { trace };