time_log v0.1.1 TimeLog.TimePlug
This plug stops the time a request takes.
The plug needs to be called as early in the endpoint.ex
as possible, ideally right after the socked received a request.
Additionally the get_duration function can be called from everywhere in order to know how long the request took so far.
Link to this section Summary
Functions
Returns the time in ms the request took so far. May be called with either a Time struct https://hexdocs.pm/elixir/Time.html or with the current conn https://hexdocs/pm/plug/Plug.Conn.html
Link to this section Functions
get_duration(Plug.Conn) :: Time
get_duration(Time) :: Time
Returns the time in ms the request took so far. May be called with either a Time struct https://hexdocs.pm/elixir/Time.html or with the current conn https://hexdocs/pm/plug/Plug.Conn.html.
Examples
iex> TimeLog.TimePlug.get_duration(conn) ~T[09:24:20.296862]
iex> start_time = Time.utc_now … … iex> TimeLog.TimePlug.get_duration(start_time) 65