Class: Arkaan::Monitoring::Results::Report

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/arkaan/monitoring/results/report.rb

Overview

A report is the result of one call to the API on one instance status route.

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ended_atDateTime

Returns the timestamp at which the report ends.

Returns:

  • (DateTime)

    the timestamp at which the report ends.



13
# File 'lib/arkaan/monitoring/results/report.rb', line 13

field :ended_at, type: DateTime

#healthyInteger

Returns the number of healthy services amongst all the monitored services.

Returns:

  • (Integer)

    the number of healthy services amongst all the monitored services.



19
# File 'lib/arkaan/monitoring/results/report.rb', line 19

field :healthy, type: Integer, default: 0

#recordsArray<Arkaan::Monitoring::Results::Record>

Returns the records linked to this report.

Returns:

  • (Array<Arkaan::Monitoring::Results::Record>)

    the records linked to this report.



23
# File 'lib/arkaan/monitoring/results/report.rb', line 23

has_many :heartbeats, class_name: 'Arkaan::Monitoring::Results::Heartbeat', inverse_of: :report

#totalInteger

Returns the total number of services monitored.

Returns:

  • (Integer)

    the total number of services monitored.



16
# File 'lib/arkaan/monitoring/results/report.rb', line 16

field :total, type: Integer, default: 0

#vigilanteArkaan::Monitoring::Vigilante

Returns the vigilante application that has created this report.

Returns:



26
# File 'lib/arkaan/monitoring/results/report.rb', line 26

belongs_to :vigilante, class_name: 'Arkaan::Monitoring::Vigilante', inverse_of: :reports

Instance Method Details

#add_heartbeat(heartbeat) ⇒ Object



28
29
30
31
32
33
# File 'lib/arkaan/monitoring/results/report.rb', line 28

def add_heartbeat(heartbeat)
  self.heartbeats << heartbeat
  self.total += 1
  self.healthy += (heartbeat.healthy ? 1 : 0)
  heartbeat.end!
end

#end!Object



39
40
41
42
# File 'lib/arkaan/monitoring/results/report.rb', line 39

def end!
  self.ended_at = DateTime.now
  self.save!
end

#start!Object



35
36
37
# File 'lib/arkaan/monitoring/results/report.rb', line 35

def start!
  self.started_at = DateTime.now
end