This is an Erlang dtrace consumer, it allows you to consume dtrace results directly from within Erlang.
erltrace is implemented as a NIF, currently it's working in a syncronouse blocking way - sorry for that. So call times are usually in the range of 200-400 microseconds so it shouldn't be that bad.
First is to create a handle:
{ok, Handle} = erltrace:open().
next is to compile a script:
erltrace:compile(
Handle,
"dtrace:::BEGIN {trace(\"Hello World\");} syscall:::entry { @num[execname] = count(); }"
).
and start the script
erltrace:go(Handle).
now you can walk or the results:
erltrace:consume(Handle).
erltrace:walk(Handle).
There is a problem in OS X that causes invalid access when there are printf elements in the trace, it works fine under Solaris So.
I borrowed heaviely from the code of node-libdtrace and python-dtrace.