Class: Sidekiq::Form526JobStatusTracker::Metrics

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/form526_job_status_tracker/metrics.rb

Overview

Helper class that fires off StatsD metrics

Instance Method Summary collapse

Constructor Details

#initialize(prefix) ⇒ Metrics

Returns a new instance of Metrics.



10
11
12
# File 'lib/sidekiq/form526_job_status_tracker/metrics.rb', line 10

def initialize(prefix)
  @prefix = prefix
end

Instance Method Details

#error_tags(error, is_bdd, service_provider) ⇒ Object (private)



46
47
48
49
50
51
52
53
# File 'lib/sidekiq/form526_job_status_tracker/metrics.rb', line 46

def error_tags(error, is_bdd, service_provider)
  tags = ["error:#{error.class}"]
  tags << "status:#{error.status_code}" if error.try(:status_code)
  tags << "message:#{error.message}" if error.try(:message)
  tags << "is_bdd:#{is_bdd}"
  tags << "service_provider:#{service_provider}"
  tags
end

#increment_exhaustedObject

Increments when a job has exhausted all its retries rubocop:enable Style/OptionalBooleanParameter



40
41
42
# File 'lib/sidekiq/form526_job_status_tracker/metrics.rb', line 40

def increment_exhausted
  StatsD.increment("#{@prefix}.exhausted")
end

#increment_non_retryable(error, is_bdd = false, service_provider = nil) ⇒ Object

Increments a non retryable error with a tag for the specific error



28
29
30
# File 'lib/sidekiq/form526_job_status_tracker/metrics.rb', line 28

def increment_non_retryable(error, is_bdd = false, service_provider = nil)
  StatsD.increment("#{@prefix}.non_retryable_error", tags: error_tags(error, is_bdd, service_provider))
end

#increment_retryable(error, is_bdd = false, service_provider = nil) ⇒ Object

Increments a retryable error with a tag for the specific error



34
35
36
# File 'lib/sidekiq/form526_job_status_tracker/metrics.rb', line 34

def increment_retryable(error, is_bdd = false, service_provider = nil)
  StatsD.increment("#{@prefix}.retryable_error", tags: error_tags(error, is_bdd, service_provider))
end

#increment_success(is_bdd = false, service_provider = nil) ⇒ Object

Increments a job success rubocop:disable Style/OptionalBooleanParameter



22
23
24
# File 'lib/sidekiq/form526_job_status_tracker/metrics.rb', line 22

def increment_success(is_bdd = false, service_provider = nil)
  StatsD.increment("#{@prefix}.success", tags: %W[is_bdd:#{is_bdd} service_provider:#{service_provider}])
end

#increment_tryObject

Increments a job try



16
17
18
# File 'lib/sidekiq/form526_job_status_tracker/metrics.rb', line 16

def increment_try
  StatsD.increment("#{@prefix}.try")
end