Alarmist.Event (alarmist v0.4.0)

View Source

Struct sent to subscribers on property changes

  • :id - which alarm
  • :state - :set or :clear
  • :description - alarm description or nil when the alarm has been cleared
  • :level - alarm severity if known to Alarmist. Defaults to :warning
  • :timestamp - the timestamp (System.monotonic_time/0) when the changed happened. See timestamp_to_utc/2 for UTC conversion.
  • :previous_state - the previous alarm state (:unknown if no previous information).
  • :previous_timestamp - the timestamp when the property changed to :previous_state. See timestamp_to_utc/2 for UTC conversion.

Summary

Functions

Convert the event's monotonic timestamp to UTC

Returns a monotonic time to UTC time mapping

Types

t()

@type t() :: %Alarmist.Event{
  description: Alarmist.alarm_description(),
  id: Alarmist.alarm_id(),
  level: Logger.level(),
  previous_state: Alarmist.alarm_state(),
  previous_timestamp: integer(),
  state: Alarmist.alarm_state(),
  timestamp: integer()
}

Functions

timestamp_to_utc(timestamp, arg \\ utc_conversion())

@spec timestamp_to_utc(
  integer(),
  {integer(), DateTime.t()}
) :: DateTime.t()

Convert the event's monotonic timestamp to UTC

utc_conversion()

@spec utc_conversion() :: {integer(), DateTime.t()}

Returns a monotonic time to UTC time mapping

This is used by timestamp_to_utc/2 by default, but it's possible to supply a custom mapping for unit test or performance reasons.

The monotonic time is in native time units.