Spaceboy. Middleware. Telemetry
(Spaceboy v0.4.0)
View Source
A plug to instrument the server with :telemetry events.
This middleware is only defined if you manually install optional dependency
:telemetry.
{:telemetry, "~> 1.0"},When plugged, the event prefix is a required option:
middleware Spaceboy.Middleware.Telemetry, event_prefix: [:my, :server]In the example above, two events will be emitted:
[:my, :server, :start]- emitted when the plug is invoked. The event carries thesystem_timeas measurement. The metadata is the wholeSpaceboy.Connunder the:connkey and any leftover options given to the plug under:options.[:my, :server, :stop]- emitted right before the request is sent. The event carries a single measurement,:duration, which is the monotonic time difference between the stop and start events. It has the same metadata as the start event, except the connection has been updated.
Note this plug measures the time between its invocation until a response
is sent. The :stop event is not guaranteed to be emitted in all error
cases, so this middleware cannot be used as a Telemetry span.
Time unit
The :duration measurements are presented in the :native time unit.
You can read more about it in the docs for System.convert_time_unit/3.