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: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Allows to periodically collect measurements and dispatch them as Telemetry event

* `[vm, memory]` - contains the total memory, process memory, and all other keys in `erlang:memory/0`
* `[vm, total_run_queue_lengths]` - returns the run queue lengths for CPU and IO schedulers. It contains the `total`, `cpu` and `io` measurements
* `[vm, system_counts]` - returns the current process, atom and port count as per `erlang:system_info/1`
* `[vm, system_counts]` - returns the current process, atom and port count as well as their respective limits as per `erlang:system_info/1`
* `[vm, persistent_term]` - number of terms and memory byte size for `persistent_term`

You can directly consume those events after adding `telemetry_poller` as a dependency.
Expand Down
5 changes: 4 additions & 1 deletion examples/TelemetryPollerVM.ex
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ defmodule TelemetryPollerVM do
"-------------\n" <>
" atom_count: #{event_measurements.atom_count}\n" <>
" port_count: #{event_measurements.port_count}\n" <>
" process_count: #{event_measurements.process_count}\n"
" process_count: #{event_measurements.process_count}\n" <>
" atom_limit: #{event_measurements.atom_limit}\n" <>
" port_limit: #{event_measurements.port_limit}\n" <>
" process_limit: #{event_measurements.process_limit}\n"
)
end
end
15 changes: 12 additions & 3 deletions examples/telemetry_poller_vm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,27 @@ handle([vm, system_counts], EventMeasurements, _EventMetadata, _HandlerConfig) -
#{
atom_count := AtomCount,
port_count := PortCount,
process_count := ProcessCount
process_count := ProcessCount,
atom_limit := AtomLimit,
port_limit := PortLimit,
process_limit := ProcessLimit
} = EventMeasurements,
% Do something with the measurements
io:format(
"system_counts~n"
"-------------~n"
" atom_count: ~p~n"
" port_count: ~p~n"
" process_count: ~p~n~n",
" process_count: ~p~n"
" atom_limit: ~p~n"
" port_limit: ~p~n"
" process_limit: ~p~n~n",
[
AtomCount,
PortCount,
ProcessCount
ProcessCount,
AtomLimit,
PortLimit,
ProcessLimit
]
).
3 changes: 3 additions & 0 deletions src/telemetry_poller.erl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ The measurement includes:
* `process_count` - the number of processes currently existing at the local node
* `atom_count` - the number of atoms currently existing at the local node
* `port_count` - the number of ports currently existing at the local node
* `process_limit` - the maximum number of processes allowed at the local node
* `atom_limit` - the maximum number of atoms allowed at the local node
* `port_limit` - the maximum number of ports allowed at the local node

### Persistent term (since 1.2.0)

Expand Down
8 changes: 7 additions & 1 deletion src/telemetry_poller_builtin.erl
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,16 @@ system_counts() ->
ProcessCount = erlang:system_info(process_count),
AtomCount = erlang:system_info(atom_count),
PortCount = erlang:system_info(port_count),
ProcessLimit = erlang:system_info(process_limit),
AtomLimit = erlang:system_info(atom_limit),
PortLimit = erlang:system_info(port_limit),
telemetry:execute([vm, system_counts], #{
process_count => ProcessCount,
atom_count => AtomCount,
port_count => PortCount
port_count => PortCount,
process_limit => ProcessLimit,
atom_limit => AtomLimit,
port_limit => PortLimit
}).

-spec persistent_term() -> ok.
Expand Down
3 changes: 2 additions & 1 deletion test/telemetry_poller_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ dispatches_system_counts(_Config) ->
{ok, _Poller} = telemetry_poller:start_link([{measurements, [system_counts]},{period, 100}]),
HandlerId = attach_to([vm, system_counts]),
receive
{event, [vm, system_counts], #{process_count := _, atom_count := _, port_count := _}, _} ->
{event, [vm, system_counts], #{process_count := _, atom_count := _, port_count := _,
process_limit := _, atom_limit := _, port_limit := _}, _} ->
telemetry:detach(HandlerId),
?assert(true)
after
Expand Down