1
0
Fork 0
mirror of synced 2024-07-04 05:50:57 +12:00

Add APM spans for request cleanup functions.

This commit is contained in:
Sam Rose 2024-03-07 14:56:30 +00:00
parent 4325b99d7d
commit ce599e775f
No known key found for this signature in database

View file

@ -1,5 +1,6 @@
import { Ctx } from "@budibase/types"
import { context } from "@budibase/backend-core"
import { tracer } from "dd-trace"
export default async (ctx: Ctx, next: any) => {
const resp = await next()
@ -12,7 +13,9 @@ export default async (ctx: Ctx, next: any) => {
let errors = []
for (let fn of current.cleanup) {
try {
await fn()
await tracer.trace("cleanup", async span => {
await fn()
})
} catch (e) {
// We catch errors here to ensure we at least attempt to run all cleanup
// functions. We'll throw the first error we encounter after all cleanup