Mctrace
Trace Erlang process messages easy
Install / Use
/learn @metachord/MctraceREADME
; -- Mode: Markdown; --
mctrace
mctrace is an Erlang tool that makes it easy to trace process messages
and produce some meaningful output like dot sequence diagrams (planned).
Project Page
Building
You need rebar (http://github.com/basho/rebar) for
building mctrace.
Just add following lines in rebar.config:
{deps, [
{mctrace, ".*", {git, "git://github.com/metachord/mctrace.git", "master"}}
]}.
Planned
- Generating dot-file for Graphviz
- Use state of process in events handling
Description
mctrace uses parse_transform to inject own hooks in some functions
(now only init/1 and terminate/2,3).
Traced process sends message to mctrace on startup which contains its pid()
and some options, like list of hooks functions and traced events.
mctrace call erlang:trace/3 function to trace specified events on process
and print it on stdout using specified hooks functions.
Usage
-
Add section in head of your erl-file:
-ifdef(MCTRACE). ... -endif. -
Put here following attributes:
-
Header file of mctrace with record definition:
-include_lib("mctrace/include/mctrace.hrl"). -
Compile option:
-compile({parse_transform, mctrace}). -
Export hooks functions (for gen_server here) if they defined in this module:
-export([ hook_send_cast/5, hook_send_call/5, hook_send_info/5, hook_receive_cast/4, hook_receive_call/5, hook_receive_info/4, hook_exit/4 ]). -
Say to
mctracewhat you want to trace and which functions use to handle specified trace events:-mct_opts([ {tracing, [send, procs, 'receive', timestamp]}, {hook_send_cast, hook_send_cast}, {hook_send_call, hook_send_call}, {hook_send_info, hook_send_info}, {hook_receive_cast, hook_receive_cast}, {hook_receive_call, hook_receive_call}, {hook_receive_info, hook_receive_info}, {hook_exit, hook_exit} ]). -
If your hooks defined in other module, write following:
... {hook_send_info, {my_hooks_mod, hook_send_info}}, ...
-
Implement hook functions (see examples in
examples/ttm/src/ttm_hooks.erl) -
Compile source code with
-D MCTRACE, or put analog torebar.config -
Run
mctraceapplication before yours -
Start your application with traced processes
Related Skills
node-connect
342.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
342.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.7kCommit, push, and open a PR
