scout_apm v0.2.10 ScoutApm.Tracing
Functions to time the execution of code.
IMPORTANT: We limit the arity of type
. These are displayed in charts
throughput the UI. These should not be generated dynamically and are designed
to be higher-level categories (ie Postgres, Redis, HTTP, etc).
Summary
Functions
Instruments the given function
, labeling it with type
and name
within Scout
Adds an instrumention entry of duration value
with units
, labeling it with type
and name
within Scout
Updates the description for the code executing within a call to instrument/3
. The description is displayed
within a Scout trace in the UI
Functions
Instruments the given function
, labeling it with type
and name
within Scout.
Within a trace in the Scout UI, the function
will appear as type/name
ie “Images/format_avatar”.
Example Usage
defmodule PhoenixApp.PageController do
use PhoenixApp.Web, :controller
import ScoutApm.Tracing
def index(conn, _params) do
instrument("Timer", "sleep", fn ->
:timer.sleep(3000)
end)
render conn, "index.html"
end
track(String.t, String.t, number, ScoutApm.Internal.Duration.unit, keyword) :: :ok | :error
Adds an instrumention entry of duration value
with units
, labeling it with type
and name
within Scout.
Units
Can be be one of :microseconds | :milliseconds | :seconds
. These come from ScoutApm.Internal.Duration.unit/0
.
Example Usage
track("Images", "resize", 200, :milliseconds)
track("HTTP", "get", 300, :milliseconds, desc: "HTTP GET http://api.github.com/")
Opts
A desc
may be provided to add a detailed background of the event. These are viewable when accessing a trace in the UI.
The duration must have actually occured
This function expects that the ScoutApm.Internal.Duration
generated by value
and units
actually occurs in
the transaction. The total time of the transaction IS NOT adjusted.
This naturally occurs when taking the output of Ecto log entries.
Updates the description for the code executing within a call to instrument/3
. The description is displayed
within a Scout trace in the UI.
This is useful for logging actual HTTP request URLs, SQL queries, etc.
Example Usage
instrument("HTTP", "httparrot", fn ->
update_desc("GET: http://httparrot.herokuapp.com/get")
HTTPoison.get! "http://httparrot.herokuapp.com/get"
end)