Upgrade dd-trace, add APM tracing around key commands, fix tags should be attached to root spans (#3243)

This commit is contained in:
Tom Moor
2022-03-14 20:03:12 -07:00
committed by GitHub
parent f3705b4a22
commit 15cecf1e53
13 changed files with 176 additions and 119 deletions

View File

@@ -1,6 +1,6 @@
import { Next } from "koa";
import tracer, { APM } from "@server/logging/tracing";
import { User, Team, ApiKey } from "@server/models";
import tracer from "@server/tracing";
import { getUserForJWT } from "@server/utils/jwt";
import { AuthenticationError, UserSuspendedError } from "../errors";
import { ContextWithState } from "../types";
@@ -100,12 +100,14 @@ export default function auth(
ctx.state.user = user;
if (tracer) {
const span = tracer.scope().active();
if (span !== null) {
span.setTag("request.userId", user.id);
span.setTag("request.teamId", user.teamId);
span.setTag("request.authType", ctx.state.authType);
}
APM.addTags(
{
"request.userId": user.id,
"request.teamId": user.teamId,
"request.authType": ctx.state.authType,
},
APM.getRootSpanFromRequestContext(ctx)
);
}
}