Module: SqsPoller::Metrics
- Defined in:
- lib/sqspoller/metrics/log_reporter.rb,
lib/sqspoller/metrics/sqs_poller_metrics.rb,
lib/sqspoller/metrics/queue_stats_reporter.rb
Defined Under Namespace
Classes: LogReporter, SqsStatsReporter
Constant Summary collapse
- UNKNOWN_MESSAGE_TYPE =
"UNKNOWN"
- TASK_SUCCESS_STATUS =
"success"
- TASK_FAILURE_STATUS =
"failed"
- NEW_RELIC_CUSTOM_METRICS_PATH =
"Custom/sqspoller/"
Class Method Summary collapse
- .disable_new_relic_metrics ⇒ Object
- .enable_new_relic_metrics ⇒ Object
- .get_message_status(task_status) ⇒ Object
- .get_message_type(task) ⇒ Object
- .get_metrics_recorder ⇒ Object
- .get_qps ⇒ Object
- .get_queue_name(task) ⇒ Object
- .get_queue_wait_time(task, timer) ⇒ Object
- .record(task, task_status, timer, elapsed_time) ⇒ Object
Class Method Details
.disable_new_relic_metrics ⇒ Object
70 71 72 |
# File 'lib/sqspoller/metrics/sqs_poller_metrics.rb', line 70 def self.disable_new_relic_metrics @new_relic_metrics_enabled = false end |
.enable_new_relic_metrics ⇒ Object
66 67 68 |
# File 'lib/sqspoller/metrics/sqs_poller_metrics.rb', line 66 def self.enable_new_relic_metrics @new_relic_metrics_enabled = true end |
.get_message_status(task_status) ⇒ Object
32 33 34 |
# File 'lib/sqspoller/metrics/sqs_poller_metrics.rb', line 32 def self.(task_status) task_status ? TASK_SUCCESS_STATUS : TASK_FAILURE_STATUS end |
.get_message_type(task) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sqspoller/metrics/sqs_poller_metrics.rb', line 19 def self.(task) = UNKNOWN_MESSAGE_TYPE begin = JSON.parse(task[:message].body, symbolize_names: true) if [:MessageType] != nil = [:MessageType] end rescue Exception => e # Ignoring When message Unknown. This happens when json is not parsable or message does not contains MessageType. end return end |
.get_metrics_recorder ⇒ Object
40 41 42 |
# File 'lib/sqspoller/metrics/sqs_poller_metrics.rb', line 40 def self.get_metrics_recorder return @agent end |
.get_qps ⇒ Object
44 45 46 |
# File 'lib/sqspoller/metrics/sqs_poller_metrics.rb', line 44 def self.get_qps return @agent.timer(:total_messages) end |
.get_queue_name(task) ⇒ Object
36 37 38 |
# File 'lib/sqspoller/metrics/sqs_poller_metrics.rb', line 36 def self.get_queue_name(task) return task[:queue_name] end |
.get_queue_wait_time(task, timer) ⇒ Object
48 49 50 51 52 |
# File 'lib/sqspoller/metrics/sqs_poller_metrics.rb', line 48 def self.get_queue_wait_time(task, timer) queue_time = task[:queue_time] start_time = timer.start_time return queue_time - start_time end |
.record(task, task_status, timer, elapsed_time) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/sqspoller/metrics/sqs_poller_metrics.rb', line 54 def self.record(task, task_status, timer, elapsed_time) return if @agent.nil? queue_name = get_queue_name(task) = (task) = (task_status) queue_wait_time = get_queue_wait_time(task, timer) local_metrics(elapsed_time, , , queue_name, queue_wait_time) new_relic_metrics(elapsed_time, , , queue_name, queue_wait_time) if @new_relic_metrics_enabled end |