diff --git a/src/instrumentation.rs b/src/instrumentation.rs index 7d988c6..9e6a2e7 100644 --- a/src/instrumentation.rs +++ b/src/instrumentation.rs @@ -115,13 +115,13 @@ impl Instrumentation { )); body.stmts = vec![ - quote!("const traced = $traced;" as Stmt, traced: Expr = traced_fn.into()), + quote!("const __apm$traced = $traced;" as Stmt, traced: Expr = traced_fn.into()), quote!( - "if (!$ch.hasSubscribers) return traced();" as Stmt, + "if (!$ch.hasSubscribers) return __apm$traced();" as Stmt, ch = ch_ident ), quote!( - "return $trace(traced, { arguments, self: this } );" as Stmt, + "return $trace(__apm$traced, { arguments, self: this } );" as Stmt, trace = trace_ident ), ]; diff --git a/tests/wasm/testdata/expected-cjs.js b/tests/wasm/testdata/expected-cjs.js index 3e1f745..ac73dd5 100644 --- a/tests/wasm/testdata/expected-cjs.js +++ b/tests/wasm/testdata/expected-cjs.js @@ -28,11 +28,11 @@ module.exports = class Up { } } fetch() { - const traced = ()=>{ + const __apm$traced = ()=>{ console.log('fetch'); }; - if (!tr_ch_apm$up_fetch.hasSubscribers) return traced(); - return tr_ch_apm$up_fetch.traceSync(traced, { + if (!tr_ch_apm$up_fetch.hasSubscribers) return __apm$traced(); + return tr_ch_apm$up_fetch.traceSync(__apm$traced, { arguments, self: this }); diff --git a/tests/wasm/testdata/expected.mjs b/tests/wasm/testdata/expected.mjs index bffd85b..5287555 100644 --- a/tests/wasm/testdata/expected.mjs +++ b/tests/wasm/testdata/expected.mjs @@ -28,11 +28,11 @@ export class Up { } } fetch() { - const traced = ()=>{ + const __apm$traced = ()=>{ console.log('fetch'); }; - if (!tr_ch_apm$up_fetch.hasSubscribers) return traced(); - return tr_ch_apm$up_fetch.traceSync(traced, { + if (!tr_ch_apm$up_fetch.hasSubscribers) return __apm$traced(); + return tr_ch_apm$up_fetch.traceSync(__apm$traced, { arguments, self: this });