Class: NatsWork::Monitoring::NewRelicReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/natswork/monitoring.rb

Overview

New Relic custom metrics (simplified)

Instance Method Summary collapse

Constructor Details

#initializeNewRelicReporter

Returns a new instance of NewRelicReporter.



142
143
144
# File 'lib/natswork/monitoring.rb', line 142

def initialize
  @enabled = defined?(NewRelic::Agent)
end

Instance Method Details

#report_counter(metric, value, _tags = {}) ⇒ Object



146
147
148
149
150
# File 'lib/natswork/monitoring.rb', line 146

def report_counter(metric, value, _tags = {})
  return unless @enabled

  NewRelic::Agent.record_metric("Custom/NatsWork/#{metric}", value)
end

#report_gauge(metric, value, _tags = {}) ⇒ Object



152
153
154
155
156
# File 'lib/natswork/monitoring.rb', line 152

def report_gauge(metric, value, _tags = {})
  return unless @enabled

  NewRelic::Agent.record_metric("Custom/NatsWork/#{metric}", value)
end

#report_timer(metric, value, _tags = {}) ⇒ Object



158
159
160
161
162
163
# File 'lib/natswork/monitoring.rb', line 158

def report_timer(metric, value, _tags = {})
  return unless @enabled

  # Convert to seconds for New Relic
  NewRelic::Agent.record_metric("Custom/NatsWork/#{metric}", value / 1000.0)
end