Skip to content

Feature: active tracing session indicator - #338

Open
kraleppa wants to merge 14 commits into
mainfrom
kraleppa/voy-329-global-active-trace-indicator-in-the-topbar
Open

kraleppa wants to merge 14 commits into
mainfrom
kraleppa/voy-329-global-active-trace-indicator-in-the-topbar

Conversation

@kraleppa

Copy link
Copy Markdown
Member

No description provided.

@kraleppa
kraleppa requested a balanced review from Copilot October 30, 2026 11:07
@kraleppa

Copy link
Copy Markdown
Member Author

@claude review

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kraleppa's task in 1m 7s —— View job


🦀 Review

Severity: 🔴 blocking · 🟡 should-fix · 🟢 nit

  • 🟡 85% lib/voyager_web/components/shell.ex:157: the indicator links to /node/:node/tracing/:id, but no such route exists, so clicking it gives a 404. The path is also built by hand with URI.encode/1, which leaves / in node names unescaped. Use ~p"/node/#{node}/tracing" for now and drop the future-tense comment.

<verdict: 0 blocking, 1 should-fix, 0 nit>

Comment thread lib/voyager_web/components/shell.ex Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Session creation can crash an open NodeInfoLive page, and the new tracing indicator links to a nonexistent session-viewer route.

3 open issues
What changed in this PR

Adds an active tracing-session indicator to Voyager’s app and settings topbars, keeping tracing activity visible across pages.

Changes:

  • Adds a LiveView hook that tracks the running session through Tracer broadcasts.
  • Displays tracing status, the traced function, trace counts, and a tooltip with session navigation.
  • Adds tests for initial state, broadcast updates, formatting, and topbar integration.
File Description
test/​voyager_web/​hooks/​tracing_status_hook_test.exs Tests indicator visibility, updates, formatting, and integration.
lib/​voyager_web/​router.ex Registers the tracing hook for app and settings sessions.
lib/​voyager_web/​hooks/​tracing_status_hook.ex Maintains the active tracing-session assign.
lib/​voyager_web/​components/​shell.ex Renders the indicator, tooltip, counts, and session link.
lib/​voyager_web/​components/​layouts.ex Passes tracing state into both topbars.

Review effort: Balanced

Comment thread lib/voyager_web/components/shell.ex Resolved
Comment thread lib/voyager_web/components/shell.ex Resolved
@kraleppa
kraleppa requested a review from hhubert6 October 30, 2026 11:22
@kraleppa
kraleppa marked this pull request as ready for review October 30, 2026 11:22

@hhubert6 hhubert6 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For me it looks better aligned to the left and with more spacing around traced mfa

Image

Tracer service essentially operates on three states: empty, loaded/created, running.
So I'm wondering if the indicator should reflect that meaning it could show loaded session and not only running.

Comment thread lib/voyager_web/components/shell.ex Resolved
@kraleppa

kraleppa commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

Tracer service essentially operates on three states: empty, loaded/created, running. So I'm wondering if the indicator should reflect that meaning it could show loaded session and not only running.

I agree other states could be shown, but it depends on what the chip should mean. The issue scopes it to running, so I assumed that it warns about potentially heavy tracing is on. If we also show idle/stopped sessions, it becomes an "open session" indicator that stays until the user closes the session.

I think both are useful, so I went with the second and kept the first visible:

  • running: green with a pulse, as before
  • ready / stopped: muted grey chip, stays until the session is closed
  • stopped on error (node down, write failure): warning color, with the reason in the tooltip

Sessions that aren't configured yet stay hidden, since there's nothing to show or link to.

cc @hhubert6

@kraleppa
kraleppa requested review from hhubert6 and a balanced review from Copilot November 2, 2026 09:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Synchronous trace-status calls can block page mounting, full-trace subscriptions add unnecessary load across open views, and the session indicator links to a placeholder rather than a session viewer.

3 open issues
3 resolved since last review

Review effort: Balanced

Comment thread lib/voyager_web/components/shell.ex Resolved
@hhubert6

hhubert6 commented Nov 2, 2026

Copy link
Copy Markdown
Member

Review of a91371e8. Finding 1 should be fixed before merge; 2-4 are nice to have.

Must fix

1. The chip can link to the wrong node and send the user to the connect page (lib/voyager_web/components/shell.ex:177)

  • What this is: A session now stays open after it stops, and it survives a disconnect. The chip builds its link from the session's node, not the connected node.
  • Problem: Trace on node A, disconnect, then connect to node B. Pages on B still show A's chip, and the tooltip doesn't name a node. The link is /node/a%40localhost/tracing, and NodeSessionHook redirects it to /. Reproduced in a test against this commit.
  • Fix: In topbar, pass node_path(@session, "tracing") into tracing_indicator as the link. Put a Node row back in the tooltip; it was removed because the node name sits right next to the chip, which is no longer always true. The settings page has no connected session, so its link can stay as it is and will still redirect in this case.
  • If we skip it: Users see a stopped session from another node as if it belonged to this one, and clicking it takes them out of the node pages. Nothing in lib starts a session yet, so this appears once the Tracing page lands.

Nice to have

2. The chip can stay on "Tracing" after the Tracer restarts (lib/voyager/services/tracer.ex:202)

  • What this is: A Writer crash restarts the Tracer, which clears the session without telling any page.
  • Problem: Open pages keep a pulsing green chip with a frozen count until the user navigates.
  • Fix: Add broadcast_session(nil) to handle_continue(:interrupt_running). The hook already clears the chip on that message.
  • If we skip it: After a rare crash, the chip says a trace is running when it isn't.

3. The chip ignores the Erlang syntax setting (lib/voyager_web/components/shell.ex:234)

  • What this is: Other pages follow TermSyntax, but the chip always uses Elixir style.
  • Problem: On an Erlang node, process pages show lists:map/2 and the chip shows :lists.map/2.
  • Fix: Branch on TermSyntax.current() in format_traced_mfa. For :erlang, return "#{module}:#{function}/#{arity || "_"}".
  • If we skip it: Only the display is inconsistent.

4. Hook tests still send the message by hand (test/voyager_web/hooks/tracing_status_hook_test.exs:116)

  • What this is: The test named "consumes an activated session's broadcast" builds {:session_updated, ...} itself. An earlier version of this test kept passing with an outdated message name while the real message crashed NodeInfoLive.
  • Problem: If the Tracer's message changes and the hook isn't updated, the message reaches NodeInfoLive and crashes it again, while this test stays green. tracer_test.exs does check the name, which lowers the risk but doesn't test the hook.
  • Fix: Add {:ok, _} = Tracer.create(:ui) to that test. The same call passed when run against this commit.
  • If we skip it: A future rename can bring the crash back without any hook test failing.

@kraleppa

kraleppa commented Nov 2, 2026 •

Copy link
Copy Markdown
Member Author

1. The chip can link to the wrong node and send the user to the connect page (lib/voyager_web/components/shell.ex:177)

We could, but it would make our URLs inconsistent: a session traced on node A would live at /node/B/tracing/:id, and the Tracing sessions list on B would need to call that out. Our UI ties every tracing session to the node it traced, so finding A's session in B's list would be misleading.

I think sessions from a previously connected node need their own handling. Either /node/A/tracing/:id should stay reachable while you're connected to B, or the node should be dropped from the session URL entirely, with a clear notice on every page while such a session is active.

Still, I'd prefer if the link details would be discussed during the implementation of the actual tracing view. Currently its temporary because those views does not exist.

But what can be done in this PR is e.g. changing color of this chip in such cases to make sure that user will understand that given tracing session comes from different node.

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.

3 participants