ObserverWeb.Tracer (Observer Web v0.2.8)

View Source

This module provides Tracer context

Summary

Functions

This function retrieves all match specs available in the Tracing page's match-spec picker.

This function retrieves all functions within the passed node and module

This function retrieves all modules within the passed node

Match specs forced in by the Profiling tools (see ObserverWeb.Tracer.Tool.forced_match_spec_keys/1), kept separate from get_default_functions_matchspecs/0 so they don't show up as user-facing options in the Tracing page's match-spec picker - capture_args is redundant there (the display tool already traces full argument values) and call_seq's captured arguments would be mislabeled as the caller by the display decoding.

This function starts the trace for the passed module/functions

This function returns the current trace server state

This function stops the trace for the passed session ID

Types

t()

@type t() :: %ObserverWeb.Tracer{
  functions_by_node: map(),
  max_messages: non_neg_integer(),
  request_pid: pid() | nil,
  session_id: binary() | nil,
  session_timeout_ms: non_neg_integer(),
  status: :idle | :running,
  tool: ObserverWeb.Tracer.Tool.t(),
  tool_opts: map(),
  tool_state: term()
}

Functions

get_default_functions_matchspecs()

@spec get_default_functions_matchspecs() :: map()

This function retrieves all match specs available in the Tracing page's match-spec picker.

NOTE: ObserverWeb.Tracer.Server concatenates the patterns of every selected key into separate match-spec clauses (not a single clause with combined actions), and Erlang match specs only run the first clause whose head matches - since every clause here matches on _, selecting more than one key at once means only the first selected key's actions actually run.

get_module_functions_info(node \\ Node.self(), module)

@spec get_module_functions_info(node :: atom(), module :: atom()) :: %{
  functions: map(),
  module: atom(),
  node: atom()
}

This function retrieves all functions within the passed node and module

get_modules(node \\ Node.self())

@spec get_modules(node :: atom()) :: list()

This function retrieves all modules within the passed node

get_tool_functions_matchspecs()

@spec get_tool_functions_matchspecs() :: map()

Match specs forced in by the Profiling tools (see ObserverWeb.Tracer.Tool.forced_match_spec_keys/1), kept separate from get_default_functions_matchspecs/0 so they don't show up as user-facing options in the Tracing page's match-spec picker - capture_args is redundant there (the display tool already traces full argument values) and call_seq's captured arguments would be mislabeled as the caller by the display decoding.

call_seq combines return_trace() and argument capture in a single clause because of the first-matching-clause limitation described in get_default_functions_matchspecs/0 - forcing return_trace + capture_args as two clauses would only ever run the first one.

start_trace(functions, attrs \\ %{})

@spec start_trace(functions :: list(), attrs :: map()) ::
  {:ok, t()} | {:error, :already_started}

This function starts the trace for the passed module/functions

Accepts an optional :tool attr (any ObserverWeb.Tracer.Tool.t(): :display - the default - :count, :duration, :call_seq or :flame_graph) selecting how trace events are reported back: :display streams each event as a {:new_trace_message, ...} message like today, other tools instead accumulate events and report a single {:tool_report, session_id, report} message when the session ends. :tool_opts passes per-tool options, e.g. %{aggregation: :avg} for :duration.

state()

@spec state() :: map()

This function returns the current trace server state

stop_trace(session_id)

@spec stop_trace(binary()) :: :ok

This function stops the trace for the passed session ID