PhoenixDevToolbar.Event (PhoenixDevToolbar v0.0.2)

Copy Markdown View Source

One recorded fact: a query, a callback, a request (ADR 05).

Plugins build events with new/4 in PhoenixDevToolbar.Plugin.collect/3. plugin is the plugin's id, kind an atom of the plugin's choosing, data a map that must already be bounded (see PhoenixDevToolbar.Truncate): it is stored as is. sid and seq are set by the toolbar on insert; plugin and span (the callback span, see PhoenixDevToolbar.Context) are stamped by the collector: span is nil only on an event not recorded yet.

Summary

Functions

Converts a native time duration to microseconds, passing nil through.

Builds an event stamped with the current system time in microseconds.

Types

t()

@type t() :: %PhoenixDevToolbar.Event{
  at: integer(),
  data: map(),
  duration: non_neg_integer() | nil,
  kind: atom(),
  plugin: atom(),
  seq: pos_integer() | nil,
  sid: String.t() | nil,
  span: non_neg_integer() | nil
}

Functions

native_to_us(native)

@spec native_to_us(integer() | nil) :: non_neg_integer() | nil

Converts a native time duration to microseconds, passing nil through.

iex> PhoenixDevToolbar.Event.native_to_us(nil)
nil

iex> PhoenixDevToolbar.Event.native_to_us(System.convert_time_unit(3, :millisecond, :native))
3000

new(plugin, kind, data, opts \\ [])

@spec new(atom(), atom(), map(), keyword()) :: t()

Builds an event stamped with the current system time in microseconds.

:duration is given in native time units (as :telemetry reports it) and stored in microseconds.