Class: VRE::Monitor

Inherits:
ZeroSilentFailures::Monitor show all
Defined in:
lib/vre/monitor.rb

Overview

Monitor functions for Rails logging and StatsD

Constant Summary collapse

CLAIM_STATS_KEY =

statsd key for api

'vre-application'
SUBMISSION_STATS_KEY =

statsd key for initial sidekiq

'worker.vre.submit_1900_job'

Instance Attribute Summary

Attributes inherited from Logging::Monitor

#service

Instance Method Summary collapse

Methods inherited from ZeroSilentFailures::Monitor

#log_silent_failure, #log_silent_failure_avoided

Methods inherited from Logging::Monitor

#parse_caller, #track_request

Constructor Details

#initializeMonitor

Returns a new instance of Monitor.



16
17
18
# File 'lib/vre/monitor.rb', line 16

def initialize
  super('vre-application')
end

Instance Method Details

#track_submission_exhaustion(msg, email = nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vre/monitor.rb', line 20

def track_submission_exhaustion(msg, email = nil)
  additional_context = {
    message: msg
  }

  if email
    # if an email address is present it means an email has been sent by vanotify
    # this means the silent failure is avoided.
    log_silent_failure_avoided(additional_context, nil, call_location: caller_locations.first)
  else
    # log_silent_failure calls the ZSF method which increases a special StatsD metric
    # and writes to the Rails log for additional ZSF tracking.
    # if no email is present, log the silent failure.
    log_silent_failure(additional_context, nil, call_location: caller_locations.first)
  end

  StatsD.increment("#{SUBMISSION_STATS_KEY}.exhausted")
  Rails.logger.error(
    "Failed all retries on VRE::Submit1900Job, last error: #{msg['error_message']}"
  )
end