Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/phoenix/live_dashboard/info/process_info_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defmodule Phoenix.LiveDashboard.ProcessInfoComponent do
@info_keys [
:initial_call,
:registered_name,
:label,
:current_function,
:status,
:message_queue_len,
Expand Down Expand Up @@ -37,6 +38,7 @@ defmodule Phoenix.LiveDashboard.ProcessInfoComponent do
<%= if @alive do %>
<Phoenix.LiveDashboard.PageBuilder.label_value_list>
<:elem label="Registered name"><%= @registered_name %></:elem>
<:elem label="Label"><%= @label %></:elem>
<:elem label="Current function"><%= @current_function %></:elem>
<:elem label="Initial call"><%= @initial_call %></:elem>
<:elem label="Status"><%= @status %></:elem>
Expand Down
37 changes: 23 additions & 14 deletions lib/phoenix/live_dashboard/system_info.ex
Original file line number Diff line number Diff line change
Expand Up @@ -345,34 +345,39 @@ defmodule Phoenix.LiveDashboard.SystemInfo do

{:ok,
info
|> Enum.map(&process_info_callback_key/1)
|> Enum.flat_map(&process_info_callback_key/1)
|> Keyword.put(:initial_call, details.initial_call)}
end
end

defp process_info_callback_key({:links, links}),
do: {:links, Enum.map(links, &pid_or_port_details/1)}
do: [{:links, Enum.map(links, &pid_or_port_details/1)}]

defp process_info_callback_key({:monitors, monitors}) do
{:monitors,
monitors
|> Enum.map(fn {_label, pid_or_port} -> pid_or_port end)
|> Enum.map(&pid_or_port_details/1)}
[
{:monitors,
monitors
|> Enum.map(fn {_label, pid_or_port} -> pid_or_port end)
|> Enum.map(&pid_or_port_details/1)}
]
end

defp process_info_callback_key({:monitored_by, monitored_by}),
do: {:monitored_by, Enum.map(monitored_by, &pid_or_port_details/1)}
do: [{:monitored_by, Enum.map(monitored_by, &pid_or_port_details/1)}]

defp process_info_callback_key({:group_leader, group_leader}),
do: {:group_leader, pid_or_port_details(group_leader)}
do: [{:group_leader, pid_or_port_details(group_leader)}]

defp process_info_callback_key({:dictionary, dictionary}) do
{:ancestors,
Keyword.get(dictionary, :"$ancestors", [])
|> Enum.map(&pid_or_port_details/1)}
[
{:ancestors,
Keyword.get(dictionary, :"$ancestors", [])
|> Enum.map(&pid_or_port_details/1)},
{:label, Keyword.get(dictionary, :"$process_label")}
]
end

defp process_info_callback_key({key, value}), do: {key, value}
defp process_info_callback_key({key, value}), do: [{key, value}]

## Applications callbacks

Expand Down Expand Up @@ -496,8 +501,12 @@ defmodule Phoenix.LiveDashboard.SystemInfo do
end

defp to_wrapped_node(type, pid, children) do
case Process.info(pid, :registered_name) do
{:registered_name, registered_name} ->
case Process.info(pid, [:registered_name, :dictionary]) do
[{:registered_name, []}, {:dictionary, dictionary}] ->
label = Keyword.get(dictionary, :"$process_label", [])
[{{type, pid, label}, children}]

[{:registered_name, registered_name}, _] ->
[{{type, pid, registered_name}, children}]

_ ->
Expand Down
8 changes: 8 additions & 0 deletions test/phoenix/live_dashboard/system_info_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ defmodule Phoenix.LiveDashboard.SystemInfoTest do
assert info[:registered_name] == Phoenix.LiveDashboard.DynamicSupervisor
assert info[:initial_call] == {:supervisor, Supervisor.Default, 1}
end

if System.otp_release() |> String.to_integer() >= 27 do
test "info with label" do
{:ok, agent_pid} = Agent.start_link(fn -> Process.set_label("test label") end)
{:ok, info} = SystemInfo.fetch_process_info(agent_pid)
assert info[:label] == "test label"
end
end
end

describe "ports" do
Expand Down
Loading