Merge pull request #12633 from Budibase/baggage-item

Set appId, userId and tenantId as baggage items in DataDog APM.
This commit is contained in:
Sam Rose 2023-12-19 16:55:34 +00:00 committed by GitHub
commit 3ed739f7de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -23,7 +23,7 @@ export default async (ctx: UserCtx, next: any) => {
if (requestAppId) { if (requestAppId) {
const span = tracer.scope().active() const span = tracer.scope().active()
span?.addTags({ app_id: requestAppId }) span?.setBaggageItem("appId", requestAppId)
} }
// deny access to application preview // deny access to application preview
@ -76,6 +76,14 @@ export default async (ctx: UserCtx, next: any) => {
return next() return next()
} }
if (ctx.user) {
const span = tracer.scope().active()
if (ctx.user._id) {
span?.setBaggageItem("userId", ctx.user._id)
}
span?.setBaggageItem("tenantId", ctx.user.tenantId)
}
const userId = ctx.user ? generateUserMetadataID(ctx.user._id!) : undefined const userId = ctx.user ? generateUserMetadataID(ctx.user._id!) : undefined
// if the user is not in the right tenant then make sure to wipe their cookie // if the user is not in the right tenant then make sure to wipe their cookie