1
0
Fork 0
mirror of synced 2024-10-03 10:36:59 +13:00

Merge branch 'master' into fix/rm-plan-business

This commit is contained in:
jvcalderon 2023-12-15 15:35:19 +01:00
commit 369048f7e2
2 changed files with 97 additions and 99 deletions

View file

@ -15,7 +15,6 @@ import { UserCtx, ContextUser } from "@budibase/types"
import tracer from "dd-trace" import tracer from "dd-trace"
export default async (ctx: UserCtx, next: any) => { export default async (ctx: UserCtx, next: any) => {
return tracer.trace("currentapp middleware", {}, async span => {
// try to get the appID from the request // try to get the appID from the request
let requestAppId = await utils.getAppIdFromCtx(ctx) let requestAppId = await utils.getAppIdFromCtx(ctx)
if (!requestAppId) { if (!requestAppId) {
@ -23,6 +22,7 @@ export default async (ctx: UserCtx, next: any) => {
} }
if (requestAppId) { if (requestAppId) {
const span = tracer.scope().active()
span?.addTags({ app_id: requestAppId }) span?.addTags({ app_id: requestAppId })
} }
@ -63,9 +63,7 @@ export default async (ctx: UserCtx, next: any) => {
roleId = roleHeader roleId = roleHeader
// Delete admin and builder flags so that the specified role is honoured // Delete admin and builder flags so that the specified role is honoured
ctx.user = users.removePortalUserPermissions( ctx.user = users.removePortalUserPermissions(ctx.user) as ContextUser
ctx.user
) as ContextUser
} }
} catch (error) { } catch (error) {
// Swallow error and do nothing // Swallow error and do nothing
@ -119,5 +117,4 @@ export default async (ctx: UserCtx, next: any) => {
return next() return next()
}) })
})
} }

View file

@ -52,7 +52,8 @@ export function processFormulas<T extends Row | Row[]>(
{ dynamic, contextRows }: FormulaOpts = { dynamic: true } { dynamic, contextRows }: FormulaOpts = { dynamic: true }
): T { ): T {
return tracer.trace("processFormulas", {}, span => { return tracer.trace("processFormulas", {}, span => {
span?.addTags({ table_id: table._id }) const numRows = Array.isArray(inputRows) ? inputRows.length : 1
span?.addTags({ table_id: table._id, dynamic, numRows })
const rows = Array.isArray(inputRows) ? inputRows : [inputRows] const rows = Array.isArray(inputRows) ? inputRows : [inputRows]
if (rows) { if (rows) {
for (let [column, schema] of Object.entries(table.schema)) { for (let [column, schema] of Object.entries(table.schema)) {
@ -77,7 +78,7 @@ export function processFormulas<T extends Row | Row[]>(
rows[i] = { rows[i] = {
...row, ...row,
[column]: tracer.trace("processStringSync", {}, span => { [column]: tracer.trace("processStringSync", {}, span => {
span?.addTags({ column }) span?.addTags({ table_id: table._id, column, static: isStatic })
return processStringSync(formula, context) return processStringSync(formula, context)
}), }),
} }