From 790d8fcf09e6a41d1a0df4fdaa3b1f20bf40358e Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 9 Feb 2024 12:41:00 +0100 Subject: [PATCH 1/5] Trace scriptRunner.execute --- packages/server/src/utilities/scriptRunner.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/server/src/utilities/scriptRunner.ts b/packages/server/src/utilities/scriptRunner.ts index 138b98fdbf..e166563f63 100644 --- a/packages/server/src/utilities/scriptRunner.ts +++ b/packages/server/src/utilities/scriptRunner.ts @@ -1,3 +1,4 @@ +import tracer from "dd-trace" import env from "../environment" import { IsolatedVM } from "../jsRunner/vm" @@ -20,8 +21,10 @@ class ScriptRunner { } execute() { - const result = this.vm.execute(this.code) - return result + return tracer.trace("scriptRunner.execute", () => { + const result = this.vm.execute(this.code) + return result + }) } } From 32723d712170535dcb9e44d211cbc79f651c37f4 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 9 Feb 2024 12:51:57 +0100 Subject: [PATCH 2/5] Trace scriptRunner --- packages/server/src/utilities/scriptRunner.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/server/src/utilities/scriptRunner.ts b/packages/server/src/utilities/scriptRunner.ts index e166563f63..ff3b37ca6b 100644 --- a/packages/server/src/utilities/scriptRunner.ts +++ b/packages/server/src/utilities/scriptRunner.ts @@ -1,4 +1,4 @@ -import tracer from "dd-trace" +import tracer, { Span } from "dd-trace" import env from "../environment" import { IsolatedVM } from "../jsRunner/vm" @@ -8,7 +8,11 @@ class ScriptRunner { private code: string private vm: IsolatedVM + private tracerSpan: Span + constructor(script: string, context: any, { parseBson = false } = {}) { + this.tracerSpan = tracer.startSpan("scriptRunner") + this.code = `(() => {${script}})();` this.vm = new IsolatedVM({ memoryLimit: env.JS_RUNNER_MEMORY_LIMIT, @@ -16,15 +20,20 @@ class ScriptRunner { }).withContext(context) if (parseBson && context.data) { + this.tracerSpan.log({ event: "isolated-vm.registering-bson" }) this.vm = this.vm.withParsingBson(context.data) } + + this.tracerSpan.log({ event: "isolated-vm.initialised" }) } execute() { - return tracer.trace("scriptRunner.execute", () => { + const result = tracer.trace("scriptRunner.execute", () => { const result = this.vm.execute(this.code) return result }) + this.tracerSpan.finish() + return result } } From 10c59e1ff6a6904f9ab97357415cf9322448d971 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 9 Feb 2024 13:17:28 +0100 Subject: [PATCH 3/5] Remove events --- packages/server/src/utilities/scriptRunner.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/server/src/utilities/scriptRunner.ts b/packages/server/src/utilities/scriptRunner.ts index ff3b37ca6b..417b847442 100644 --- a/packages/server/src/utilities/scriptRunner.ts +++ b/packages/server/src/utilities/scriptRunner.ts @@ -20,11 +20,8 @@ class ScriptRunner { }).withContext(context) if (parseBson && context.data) { - this.tracerSpan.log({ event: "isolated-vm.registering-bson" }) this.vm = this.vm.withParsingBson(context.data) } - - this.tracerSpan.log({ event: "isolated-vm.initialised" }) } execute() { From f7583b24314b92f0c874b7ffccde38819f7e0ac9 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 9 Feb 2024 13:20:21 +0100 Subject: [PATCH 4/5] Add options --- packages/server/src/utilities/scriptRunner.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/server/src/utilities/scriptRunner.ts b/packages/server/src/utilities/scriptRunner.ts index 417b847442..72042a5791 100644 --- a/packages/server/src/utilities/scriptRunner.ts +++ b/packages/server/src/utilities/scriptRunner.ts @@ -11,7 +11,7 @@ class ScriptRunner { private tracerSpan: Span constructor(script: string, context: any, { parseBson = false } = {}) { - this.tracerSpan = tracer.startSpan("scriptRunner") + this.tracerSpan = tracer.startSpan("scriptRunner", { tags: { parseBson } }) this.code = `(() => {${script}})();` this.vm = new IsolatedVM({ @@ -25,10 +25,14 @@ class ScriptRunner { } execute() { - const result = tracer.trace("scriptRunner.execute", () => { - const result = this.vm.execute(this.code) - return result - }) + const result = tracer.trace( + "scriptRunner.execute", + { childOf: this.tracerSpan }, + () => { + const result = this.vm.execute(this.code) + return result + } + ) this.tracerSpan.finish() return result } From 86350af7740a5eab0c19fbdc6892be6ab6759e6c Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Fri, 9 Feb 2024 12:31:02 +0000 Subject: [PATCH 5/5] Bump version to 2.18.1 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 91cecd5db3..abf1e4d21a 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.18.0", + "version": "2.18.1", "npmClient": "yarn", "packages": [ "packages/*",