Merge pull request #12711 from Budibase/attach-user-to-spans

Attach authenticated user to DataDog spans.
This commit is contained in:
Sam Rose 2024-01-05 14:00:48 +00:00 committed by GitHub
commit 3a34576637
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import * as identity from "../context/identity"
import env from "../environment"
import { Ctx, EndpointMatcher, SessionCookie } from "@budibase/types"
import { InvalidAPIKeyError, ErrorCode } from "../errors"
import tracer from "dd-trace"
const ONE_MINUTE = env.SESSION_UPDATE_PERIOD
? parseInt(env.SESSION_UPDATE_PERIOD)
@ -166,6 +167,19 @@ export default function (
if (!authenticated) {
authenticated = false
}
if (user) {
tracer.setUser({
id: user?.id,
tenantId: user?.tenantId,
admin: user?.admin,
builder: user?.builder,
budibaseAccess: user?.budibaseAccess,
status: user?.status,
roles: user?.roles,
})
}
// isAuthenticated is a function, so use a variable to be able to check authed state
finalise(ctx, { authenticated, user, internal, version, publicEndpoint })