-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Profiling process and all calls happening in it #47
Comments
So you want a limited number of call traces, but only for a specific pid? |
I want to listen for all calls within given PID. Alternatively (in this particular case) if there would be a possibility for time limit (like in #48) then I could listen on |
👋 This doesn't produce a flamegraph / flamechart (yet), but I wonder if something like this could work Ranch handler with a Telemetry spandefmodule Echo do
@behaviour :ranch_protocol
def child_spec(opts) do
:ranch.child_spec(__MODULE__, :ranch_tcp, opts, __MODULE__, [])
end
def start_link(ref, transport, opts) do
{:ok, :proc_lib.spawn_link(__MODULE__, :init, [ref, transport, opts])}
end
def init(ref, transport, _opts) do
{:ok, socket} = :ranch.handshake(ref)
loop(socket, transport)
end
defp loop(socket, transport) do
case transport.recv(socket, 0, :infinity) do
{:ok, data} ->
:telemetry.span([:ranch, :handler], %{}, fn ->
_work = Enum.each(1..100, fn _ -> String.codepoints(data) end)
{transport.send(socket, data), %{}}
end)
loop(socket, transport)
_ ->
transport.close(socket)
end
end
end Naive
|
I am working on profiling Ranch protocol handler which is implemented as
gen_statem
. Currently I am tracing allhandle_event/4
function calls, but that results in a lot of separate traces and it is hard to see overall picture. Would it be possible to trace single process (ideally running it from source code)? It would make profiling such code way easier than current workaround (I have tried monitoringenter_loop
which I use, but that never produced any output).The text was updated successfully, but these errors were encountered: