fix: reset span name and http.route in static file middleware (#2856)

This commit is contained in:
Luca Casonato
2025-04-23 14:35:39 +02:00
committed by GitHub
parent 149509995e
commit b4fd717c6c
2 changed files with 8 additions and 1 deletions
+7 -1
View File
@@ -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<T>(): MiddlewareFn<T> {
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,
+1
View File
@@ -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 };