Skip to content

Conversation

kraleppa
Copy link
Member

@kraleppa kraleppa commented Oct 15, 2025

In this PR I introduced a new trace associated with LiveView diffs that are sent to the browser from LiveView via WebSocket. They can be accessed via global traces view, after selecting corresponding option in the filters form

Traces as a structure needs some unification, but since this PR is already big, I decided to refactor it in the next PR

Screen.Recording.2025-10-16.at.12.14.19.mov

@kraleppa kraleppa linked an issue Oct 15, 2025 that may be closed by this pull request
@kraleppa kraleppa requested review from GuzekAlan, hhubert6 and srzeszut and removed request for hhubert6 October 16, 2025 10:28
@kraleppa kraleppa marked this pull request as ready for review October 16, 2025 10:28
Copy link
Contributor

@GuzekAlan GuzekAlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since some of the code will change after the refactoring of traces I think it is ok. (only left some nitpicks). Works well. Good Job 🐬

Enables tracing for a specific process.
"""
@spec process(pid(), flags :: list()) :: {:ok, term()} | {:error, term()}
def process(pid, flags) when is_list(flags) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: you could also add is_pid

It stores the trace in table associated with `pid` given in `Trace` struct.
"""
@spec insert(Trace.t()) :: true
def insert(%Trace{} = trace) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about adding

defgaurd is_trace(trace) when is_struct(trace, Trace) or is_struct(trace, DiffTrace)

@type continuation() :: TracesStorage.continuation()
@type ets_table_id() :: TracesStorage.ets_table_id()
@type table_identifier() :: TracesStorage.table_identifier()
@type trace() :: Trace.t() | DiffTrace.t()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use LiveDebugger.API.TracesStorage.trace() ?

trace_diffs = Keyword.get(opts, :trace_diffs, false)

match_spec(node_id, functions, execution_times)
match_spec(node_id, functions, execution_times, trace_diffs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just do this

Suggested change
match_spec(node_id, functions, execution_times, trace_diffs)
match_spec(node_id, functions, execution_times)
|> maybe_attach_diff_spec(trace_diffs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tracing LiveView diffs

2 participants