Merge branch 'master' into remove-vm2-from-stringtemplates
This commit is contained in:
commit
72802961ad
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "2.18.0",
|
||||
"version": "2.18.1",
|
||||
"npmClient": "yarn",
|
||||
"packages": [
|
||||
"packages/*",
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import tracer, { Span } from "dd-trace"
|
||||
import env from "../environment"
|
||||
import { IsolatedVM } from "../jsRunner/vm"
|
||||
|
||||
|
@ -7,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", { tags: { parseBson } })
|
||||
|
||||
this.code = `(() => {${script}})();`
|
||||
this.vm = new IsolatedVM({
|
||||
memoryLimit: env.JS_RUNNER_MEMORY_LIMIT,
|
||||
|
@ -20,9 +25,17 @@ class ScriptRunner {
|
|||
}
|
||||
|
||||
execute() {
|
||||
const result = tracer.trace(
|
||||
"scriptRunner.execute",
|
||||
{ childOf: this.tracerSpan },
|
||||
() => {
|
||||
const result = this.vm.execute(this.code)
|
||||
return result
|
||||
}
|
||||
)
|
||||
this.tracerSpan.finish()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
export default ScriptRunner
|
||||
|
|
Loading…
Reference in New Issue