fix: reset span name and http.route in static file middleware (#2856)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user