You can now specify that programmatic profiling ignores processes that are inside foreign calls. See hcl:start-profiling .
hcl:start-profiling