Skip to content

Commit d789702

Browse files
committed
Display process label in application and process views
1 parent 296c2a9 commit d789702

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

lib/phoenix/live_dashboard/info/process_info_component.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ defmodule Phoenix.LiveDashboard.ProcessInfoComponent do
66
@info_keys [
77
:initial_call,
88
:registered_name,
9+
:label,
910
:current_function,
1011
:status,
1112
:message_queue_len,
@@ -37,6 +38,7 @@ defmodule Phoenix.LiveDashboard.ProcessInfoComponent do
3738
<%= if @alive do %>
3839
<Phoenix.LiveDashboard.PageBuilder.label_value_list>
3940
<:elem label="Registered name"><%= @registered_name %></:elem>
41+
<:elem label="Label"><%= @label %></:elem>
4042
<:elem label="Current function"><%= @current_function %></:elem>
4143
<:elem label="Initial call"><%= @initial_call %></:elem>
4244
<:elem label="Status"><%= @status %></:elem>

lib/phoenix/live_dashboard/system_info.ex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ defmodule Phoenix.LiveDashboard.SystemInfo do
319319
:monitors,
320320
:monitored_by,
321321
:registered_name,
322+
:label,
322323
:current_function,
323324
:status,
324325
:message_queue_len,
@@ -496,8 +497,12 @@ defmodule Phoenix.LiveDashboard.SystemInfo do
496497
end
497498

498499
defp to_wrapped_node(type, pid, children) do
499-
case Process.info(pid, :registered_name) do
500-
{:registered_name, registered_name} ->
500+
case Process.info(pid, [:registered_name, :dictionary]) do
501+
[{:registered_name, []}, {:dictionary, dictionary}] ->
502+
label = Keyword.get(dictionary, :"$process_label", [])
503+
[{{type, pid, label}, children}]
504+
505+
[{:registered_name, registered_name}, _] ->
501506
[{{type, pid, registered_name}, children}]
502507

503508
_ ->

test/phoenix/live_dashboard/system_info_test.exs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ defmodule Phoenix.LiveDashboard.SystemInfoTest do
9999
assert info[:registered_name] == Phoenix.LiveDashboard.DynamicSupervisor
100100
assert info[:initial_call] == {:supervisor, Supervisor.Default, 1}
101101
end
102+
103+
if System.otp_release() |> String.to_integer() >= 27 do
104+
test "info with label" do
105+
{:ok, agent_pid} = Agent.start_link(fn -> Process.set_label("test label") end)
106+
{:ok, info} = SystemInfo.fetch_process_info(agent_pid)
107+
assert info[:label] == "test label"
108+
end
109+
end
102110
end
103111

104112
describe "ports" do

0 commit comments

Comments
 (0)