Skip to content

Commit

Permalink
wrap and unwrap each callback
Browse files Browse the repository at this point in the history
  • Loading branch information
binaryseed committed Jun 4, 2020
1 parent 44fe435 commit 8e3e7b1
Showing 1 changed file with 6 additions and 22 deletions.
28 changes: 6 additions & 22 deletions lib/plug/cowboy/telemetry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ defmodule Plug.Cowboy.Telemetry do
body: body
}
)

_ ->
:ignore
end

:cowboy_stream.info(stream_id, info, state)
end

def info(stream_id, info, state) do
case info do
{:EXIT, _pid, reason} ->
:telemetry.execute(
[:plug_cowboy, :stream_handler, :exception],
Expand All @@ -53,22 +43,16 @@ defmodule Plug.Cowboy.Telemetry do
:ignore
end

:cowboy_stream.info(stream_id, info, state)
end

def data(stream_id, is_fin, data, [state | _]) do
data(stream_id, is_fin, data, state)
end

def data(stream_id, is_fin, data, state) do
:cowboy_stream.data(stream_id, is_fin, data, state)
{commands, state} = :cowboy_stream.info(stream_id, info, state)
{commands, [state, start_time]}
end

def terminate(stream_id, reason, [state | _]) do
terminate(stream_id, reason, state)
def data(stream_id, is_fin, data, [state, start_time]) do
{commands, state} = :cowboy_stream.data(stream_id, is_fin, data, state)
{commands, [state, start_time]}
end

def terminate(stream_id, reason, state) do
def terminate(stream_id, reason, [state, _start_time]) do
:cowboy_stream.terminate(stream_id, reason, state)
end

Expand Down

0 comments on commit 8e3e7b1

Please sign in to comment.