Skip to content

Commit

Permalink
Prefer process name over label if both are set (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
KernelMadness authored Aug 15, 2024
1 parent c1f57b8 commit 4e6e8b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/phoenix/live_dashboard/system_info.ex
Original file line number Diff line number Diff line change
Expand Up @@ -803,8 +803,8 @@ defmodule Phoenix.LiveDashboard.SystemInfo do
initial_call = Keyword.get(dictionary, :"$initial_call", initial_call)

name =
format_process_label(Keyword.get(dictionary, :"$process_label")) ||
format_registered_name(name) ||
format_registered_name(name) ||
format_process_label(Keyword.get(dictionary, :"$process_label")) ||
format_initial_call(initial_call)

{name, initial_call}
Expand Down
12 changes: 12 additions & 0 deletions test/phoenix/live_dashboard/system_info_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ defmodule Phoenix.LiveDashboard.SystemInfoTest do
assert pid == {:pid, agent_pid}
assert name == {:name_or_initial_call, "test label"}
end

test "all with search by name if both name and label are set" do
{:ok, agent_pid} =
Agent.start_link(fn -> Process.set_label("test label") end, name: :test_agent)

{pids, _count, _} =
SystemInfo.fetch_processes(node(), "test_agent", :memory, :asc, 100)

assert [[pid, name | _]] = pids
assert pid == {:pid, agent_pid}
assert name == {:name_or_initial_call, ":test_agent"}
end
end

test "allows previous reductions param" do
Expand Down

0 comments on commit 4e6e8b9

Please sign in to comment.