View Source Tracer (Exrun v0.2.1)
Main interface for tracing functionallity.
Usage:
use Tracer
trace Map.new()
Options:
:node
- specified the node, on which trace should be started.:limit
- specifies the limit, that should be used on collectable process. Limit options are merged with actually setted. It is possible to specify it per configuration as env:limit
for application:exrun
.The following limit options are available:
:time
- specifies the time in milliseconds, where should the rate be applied. Default specified by environments. (Default: 1000):rate
- specifies the limit of trace messages per time, if trace messages will be over this limit, the collectable process will stop and clear all traces. Default specified by environments. (Default: 250):overall
- set the absolute limit for messages. After reaching this limit, the collactable process will clear all traces and stops. Default specified by environments. (Default: nil)
Additionally limit can be specified as
limit: 5
, than it equivalent tolimit: %{overall: 5}
:formatter_local
- flag for setting, where formatter process should be started. If set tofalse
, then the formatter process will be started on remote node, if set totrue
, on a local machine. Defaults set tofalse
. Tracer can trace on nodes, where elixir is not installed. If formatter_local set to true, there will be only 2 modules loaded on remote erlang node (Tracer.Utils and Tracer.Collector), which forward messages to the connected node. If formatter_local set to false, than formatter started on remote node and it load all modules from elixir application, because for formatting traces there should be loaded at least all Inspect modules.:formatter
- own formatter function, example because you try to trace different inspect function. Formatter is either a fun or tuple{module, function, opts}
.:format_opts
- any format options, which will be passed toinspect/2
. Per default structs are disabled.:io
- specify io process, which should handle io from a tracer or a tuple{init_fun, handle_fun}
, which handles initialization and io process.init_fun
has zero arguments and should returnio
, which will be passed tohandle_fun
together with a message.:unlink
- tracer won't be stoped once a process started it terminates. (should be used for tracing into files or using network):file
- specifies a file, where traces should be saved. Option[file: "/tmp/trace.log"]
is a shortcut for[unlink: true, io: {{File, :open!, ["/tmp/trace.log", [:append]]}, {IO, :puts, []}}]
Link to this section Summary
Functions
Stop tracing
Ensure tracer started
Get status of tracer.
Options
The following options are available
Stop tracing
Link to this section Functions
Stop tracing
Ensure tracer started
Get status of tracer.
options
Options
The following options are available:
:stack
- stacktrace for the process call should be printed:exported
- only exported functions should be printed:no_return
- no returns should be printed for a calls:pid
- specify pid, you want to trace, otherwise all processes are traced
examples
Examples
iex> import Tracer # should be to simplify using of trace
nil
iex> trace :lists.seq
{:ok, 2}
iex> trace :lists.seq/2
{:ok, 1}
iex> trace :lists.seq(1, 10)
{:ok, 2}
iex> trace :lists.seq(a, b) when a < 10 and b > 25
{:ok, 2}
iex> trace :maps.get(:undefined, _), [:stack]
{:ok, 2}
iex> trace :maps.get/2, [limit: %{overall: 100, rate: 50, time: 50}]
{:ok, 2}
Stop tracing