plug_telemetry_server_timing v0.1.0 Plug.Telemetry.ServerTiming View Source
This plug provide support for Server-Timing
header that allows to
display server-side measurements in browser developer tools and access it
programatically via Performance API in JavaScript.
Usage
Just add it as a plug into your pipeline:
plug Plug.Telemetry.ServerTiming
And call install/1
with list of {event_name, measurement}
in your
application startup, for example for Phoenix and Ecto application:
Plug.Telemetry.ServerTiming.install([
{[:phoenix, :endpoint, :stop], :duration},
{[:my_app, :repo, :query], :queue_time},
{[:my_app, :repo, :query], :query_time},
{[:my_app, :repo, :query], :decode_time}
])
And then it will be visible in your DevTools.
Important
You need to place this plug BEFOREPlug.Telemetry
call as otherwise it
will not see it's events (before_send
callbacks are called in reverse order
of declaration, so this one need to be added before Plug.Telemetry
one.
Caveats
This will not respond with events that happened in separate processes, only events that happened in the Plug process will be recorded.
Link to this section Summary
Functions
Define which events should be available within response headers.
Link to this section Functions
install(events)
View Sourceinstall(events) :: :ok when events: map() | [{:telemetry.event_name(), atom()}]
Define which events should be available within response headers.