Add options
This commit is contained in:
parent
a67885d112
commit
f7583b2431
|
@ -11,7 +11,7 @@ class ScriptRunner {
|
||||||
private tracerSpan: Span
|
private tracerSpan: Span
|
||||||
|
|
||||||
constructor(script: string, context: any, { parseBson = false } = {}) {
|
constructor(script: string, context: any, { parseBson = false } = {}) {
|
||||||
this.tracerSpan = tracer.startSpan("scriptRunner")
|
this.tracerSpan = tracer.startSpan("scriptRunner", { tags: { parseBson } })
|
||||||
|
|
||||||
this.code = `(() => {${script}})();`
|
this.code = `(() => {${script}})();`
|
||||||
this.vm = new IsolatedVM({
|
this.vm = new IsolatedVM({
|
||||||
|
@ -25,10 +25,14 @@ class ScriptRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
execute() {
|
execute() {
|
||||||
const result = tracer.trace("scriptRunner.execute", () => {
|
const result = tracer.trace(
|
||||||
const result = this.vm.execute(this.code)
|
"scriptRunner.execute",
|
||||||
return result
|
{ childOf: this.tracerSpan },
|
||||||
})
|
() => {
|
||||||
|
const result = this.vm.execute(this.code)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
)
|
||||||
this.tracerSpan.finish()
|
this.tracerSpan.finish()
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue