Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/instrumentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl Instrumentation {
self.insert_tracing(body);
}
}
false
true
}

pub fn visit_mut_var_decl(&mut self, node: &mut VarDecl) -> bool {
Expand Down
1 change: 1 addition & 0 deletions tests/instrumentor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod index_cjs;
mod injection_failure;
mod multiple_class_method_cjs;
mod multiple_load_cjs;
mod nested_functions;
mod object_method_cjs;
mod polyfill_cjs;
mod polyfill_mjs;
18 changes: 18 additions & 0 deletions tests/nested_functions/mod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2025 Datadog, Inc.
**/

function fastify() {
const fastify = {
addHook
}

function addHook() {
return 'Hook added';
}

return fastify
}

module.exports = fastify;
15 changes: 15 additions & 0 deletions tests/nested_functions/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::common::*;
use orchestrion_js::*;

#[test]
fn nested_fn() {
transpile_and_test(
file!(),
false,
Config::new_single(InstrumentationConfig::new(
"nested_fn",
test_module_matcher(),
FunctionQuery::function_declaration("addHook", FunctionKind::Sync),
)),
);
}
16 changes: 16 additions & 0 deletions tests/nested_functions/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2025 Datadog, Inc.
**/
const fastify = require('./instrumented.js');
const { assert, getContext } = require('../common/preamble.js');
const context = getContext('orchestrion:undici:nested_fn');
(async () => {
const f = fastify()
const result = f.addHook()
assert.strictEqual(result, 'Hook added');
assert.deepStrictEqual(context, {
start: true,
end: true,
});
})();