Files
outline/server/middlewares/requestTracer.ts
Tom Moor bf45e97641 chore: Enforce type import consistency (#10968)
* Update types

* fix circular dep

* type imports

* lint type imports and --fix
2025-12-19 23:07:02 -05:00

25 lines
657 B
TypeScript

import type { Context, Next } from "koa";
import { addTags, getRootSpanFromRequestContext } from "@server/logging/tracer";
export default function requestTracer() {
return async function requestTracerMiddleware(ctx: Context, next: Next) {
const params = ctx.request.body ?? ctx.request.query;
for (const key in params) {
if (key === "id" || key.endsWith("Id")) {
const value = params[key];
if (typeof value === "string") {
addTags(
{
[`resource.${key}`]: value,
},
getRootSpanFromRequestContext(ctx)
);
}
}
}
await next();
};
}