fix: add more request instrumentation (#3300)

This commit is contained in:
Marvin Hagemeister
2025-09-01 17:30:12 +02:00
committed by GitHub
parent 1c097cfd3b
commit 5d052c0fdb
2 changed files with 54 additions and 30 deletions
+14 -2
View File
@@ -16,6 +16,7 @@ import {
newRouteCmd,
} from "./commands.ts";
import { isLazy } from "./utils.ts";
import { recordSpanError, tracer } from "./otel.ts";
export interface FreshFsMod<State> {
config?: RouteConfig;
@@ -140,8 +141,19 @@ export function fsItemsToCommands<State>(
let config: RouteConfig = {};
if (isLazy(rawMod)) {
normalized = async () => {
const result = await rawMod();
return normalizeRoute(filePath, result, routePattern);
return await tracer.startActiveSpan("lazy-route", {
attributes: { "fresh.route_name": rawMod.name ?? "anonymous" },
}, async (span) => {
try {
const result = await rawMod();
return normalizeRoute(filePath, result, routePattern);
} catch (err) {
recordSpanError(span, err);
throw err;
} finally {
span.end();
}
});
};
config.methods = item.overrideConfig?.methods ?? "ALL";