From 8e3e7b14893e37b8933cd87f4ba3de2b6f749457 Mon Sep 17 00:00:00 2001 From: Vince Foley Date: Thu, 4 Jun 2020 12:40:46 -0700 Subject: [PATCH] wrap and unwrap each callback --- lib/plug/cowboy/telemetry.ex | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/lib/plug/cowboy/telemetry.ex b/lib/plug/cowboy/telemetry.ex index 1a63564..3c17b50 100644 --- a/lib/plug/cowboy/telemetry.ex +++ b/lib/plug/cowboy/telemetry.ex @@ -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], @@ -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