Add APM spans for request cleanup functions.
This commit is contained in:
parent
4325b99d7d
commit
ce599e775f
1 changed files with 4 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
import { Ctx } from "@budibase/types"
|
import { Ctx } from "@budibase/types"
|
||||||
import { context } from "@budibase/backend-core"
|
import { context } from "@budibase/backend-core"
|
||||||
|
import { tracer } from "dd-trace"
|
||||||
|
|
||||||
export default async (ctx: Ctx, next: any) => {
|
export default async (ctx: Ctx, next: any) => {
|
||||||
const resp = await next()
|
const resp = await next()
|
||||||
|
@ -12,7 +13,9 @@ export default async (ctx: Ctx, next: any) => {
|
||||||
let errors = []
|
let errors = []
|
||||||
for (let fn of current.cleanup) {
|
for (let fn of current.cleanup) {
|
||||||
try {
|
try {
|
||||||
await fn()
|
await tracer.trace("cleanup", async span => {
|
||||||
|
await fn()
|
||||||
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// We catch errors here to ensure we at least attempt to run all cleanup
|
// 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
|
// functions. We'll throw the first error we encounter after all cleanup
|
||||||
|
|
Loading…
Reference in a new issue