fix: add more request instrumentation (#3300)
This commit is contained in:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user