Skip to content

Commit

Permalink
Add raw check logs to show check result audit
Browse files Browse the repository at this point in the history
  • Loading branch information
v9n committed Dec 29, 2019
1 parent 45b963f commit 2dadd3e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ class Check
field :auth_password, type: String

belongs_to :user

has_many :assertions, dependent: :destroy
has_many :incidents, dependent: :destroy
has_many :check_logs, dependent: :destroy
has_one :daily_uptime, dependent: :destroy

index({ created_at: 1, updated_at: 1 }, background: true)
Expand Down
13 changes: 13 additions & 0 deletions app/models/check_log.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

class CheckLog
include Mongoid::Document

field :response, type: Hash

field :region, type: String
field :agent, type: String

belongs_to :check

end
3 changes: 3 additions & 0 deletions app/workers/check_to_create_incident_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def perform(check_id, raw_check_response)
check = Check.find(check_id)
logger.info raw_check_response

# TODO: CheckLog should be in a circular buffer
CheckLog.create!(response: JSON.parse(raw_check_response), check: check)

check_response = CheckResponse.create_from_raw_result raw_check_response

# TODO: check for down/non 2xx,3xx event if no assertion was created
Expand Down
38 changes: 38 additions & 0 deletions app/workers/destroy_check_worker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# frozen_string_literal: true

class DestroyCheckWorker
include Sidekiq::Worker

# @param sting check id
def perform(check_id)
@check = Check.find(check_id)

delete_incident!
delete_assertion!
delete_check_response!
delete_daily_uptime!
delete_notification!
end

private

def delete_incident!

end

def delete_assertion!

end

def delete_check_response!

end

def delete_daily_uptime!

end

def delete_notification!

end
end

0 comments on commit 2dadd3e

Please sign in to comment.