Module: Common::Client::Concerns::Monitoring

Extended by:
ActiveSupport::Concern
Included in:
Apps::Client, BGS::Service, BID::Service, BenefitsEducation::Service, BenefitsIntakeService::Service, BenefitsReferenceData::Service, BipClaims::Service, CARMA::Client::MuleSoftAuthTokenClient, CARMA::Client::MuleSoftClient, Caseflow::Service, CentralMail::Service, Chip::Service, DebtManagementCenter::BaseService, DebtManagementCenter::Sharepoint::Request, DebtManagementCenter::VBS::Request, DecisionReview::PdfValidation::Service, DecisionReview::Service, DecisionReviewV1::Service, EVSS::Letters::DownloadService, EVSS::Service, Form1010Ezr::Service, Forms::Client, HCA::EnrollmentEligibility::Service, HCA::Service, IHub::Appointments::Service, LGY::Service, Lighthouse::VeteransHealth::Client, MDOT::Client, MPI::Service, MailAutomation::Client, MedicalCopays::Request, PagerDuty::ExternalServices::Service, Post911SOB::DGIB::Client, Preneeds::Service, RES::Service, Salesforce::Service, Search::Service, SearchClickTracking::Service, SearchGsa::Service, SearchTypeahead::Service, VAProfile::AddressValidation::Service, VAProfile::Communication::Service, VAProfile::ContactInformation::Service, VAProfile::Demographics::Service, VAProfile::MilitaryPersonnel::Service, VAProfile::Person::Service, VAProfile::V2::ContactInformation::Service, VAProfile::V2::Person::Service, VAProfile::V3::AddressValidation::Service, VAProfile::VeteranStatus::Service, VRE::Service, VirtualRegionalOffice::Client
Defined in:
lib/common/client/concerns/monitoring.rb

Instance Method Summary collapse

Instance Method Details

#increment(key, tags = nil) ⇒ Object (private)



33
34
35
36
37
38
39
40
# File 'lib/common/client/concerns/monitoring.rb', line 33

def increment(key, tags = nil)
  StatsDMetric.new(key:).save
  if tags.blank?
    StatsD.increment(key)
  else
    StatsD.increment(key, tags:)
  end
end

#increment_failure(caller, error) ⇒ Object (private)



25
26
27
28
29
30
31
# File 'lib/common/client/concerns/monitoring.rb', line 25

def increment_failure(caller, error)
  clean_error_class = error.class.to_s.gsub(':', '')
  tags = ["error:#{clean_error_class}"]
  tags << "status:#{error.status}" if error.try(:status)

  increment("#{self.class::STATSD_KEY_PREFIX}.#{caller}.fail", tags)
end

#increment_total(caller) ⇒ Object (private)



21
22
23
# File 'lib/common/client/concerns/monitoring.rb', line 21

def increment_total(caller)
  increment("#{self.class::STATSD_KEY_PREFIX}.#{caller}.total")
end

#with_monitoring(trace_location = 1) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/common/client/concerns/monitoring.rb', line 9

def with_monitoring(trace_location = 1)
  caller = caller_locations(trace_location, 1)[0].label
  yield
rescue => e
  increment_failure(caller, e)
  raise e
ensure
  increment_total(caller)
end