mirror of
https://github.com/outline/outline.git
synced 2026-12-04 10:24:43 +03:00
* chore: Upgrade koa-helmet to v9 and koa-body to v8 * fix: Keep decimal parsing for pagination limit and offset
28 lines
772 B
TypeScript
28 lines
772 B
TypeScript
import type { Context, Next } from "koa";
|
|
import { addTags, getRootSpanFromRequestContext } from "@server/logging/tracer";
|
|
import { RequestHelper } from "@server/utils/RequestHelper";
|
|
|
|
export default function requestTracer() {
|
|
return async function requestTracerMiddleware(ctx: Context, next: Next) {
|
|
const params = ctx.request.body
|
|
? RequestHelper.getBodyObject(ctx.request)
|
|
: 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();
|
|
};
|
|
}
|