Skip to content
Draft
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
12 changes: 12 additions & 0 deletions lib/phoenix/live_dashboard/system_info.ex
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ defmodule Phoenix.LiveDashboard.SystemInfo do
:rpc.call(node, __MODULE__, :memory_allocators_callback, [max_carrier_sizes])
end

def fetch_instrument_allocations(node) do
:rpc.call(node, __MODULE__, :instrument_allocations_callback, [])
end

## System callbacks

@doc false
Expand Down Expand Up @@ -269,6 +273,14 @@ defmodule Phoenix.LiveDashboard.SystemInfo do
end)
end

def instrument_allocations_callback() do
if Code.ensure_loaded?(:instrument) do
:instrument.allocations()
else
{:error, :instrument_not_available}
end
end

## Process Callbacks

@processes_keys [
Expand Down
17 changes: 17 additions & 0 deletions test/phoenix/live_dashboard/system_info_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,21 @@ defmodule Phoenix.LiveDashboard.SystemInfoTest do
] = list
end
end

describe "fetch_instrument_allocations" do
test "works" do
assert {:ok, {128, 0, allocs}} = SystemInfo.fetch_instrument_allocations(node())

assert %{
system: %{binary: binary_tuple, nif_internal: nif_tuple, port: port_tuple},
prim_file: %{},
tcp_inet: %{drv_internal: drv_tuple}
} = allocs

assert tuple_size(binary_tuple) == 18
assert tuple_size(nif_tuple) == 18
assert tuple_size(port_tuple) == 18
assert tuple_size(drv_tuple) == 18
end
end
end