Add options

This commit is contained in:
Adria Navarro 2024-02-09 13:20:21 +01:00
parent a67885d112
commit f7583b2431
1 changed files with 9 additions and 5 deletions

View File

@ -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
}