Class: NatsWork::Monitoring::Coordinator
- Inherits:
-
Object
- Object
- NatsWork::Monitoring::Coordinator
- Defined in:
- lib/natswork/monitoring.rb
Overview
Monitoring coordinator that manages all reporters
Class Method Summary collapse
Instance Method Summary collapse
- #add_reporter(reporter) ⇒ Object
- #disable! ⇒ Object
- #enable! ⇒ Object
-
#initialize ⇒ Coordinator
constructor
A new instance of Coordinator.
- #remove_reporter(reporter) ⇒ Object
- #report_counter(metric, value, tags = {}) ⇒ Object
- #report_gauge(metric, value, tags = {}) ⇒ Object
- #report_histogram(metric, value, tags = {}) ⇒ Object
- #report_timer(metric, value, tags = {}) ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize ⇒ Coordinator
Returns a new instance of Coordinator.
243 244 245 246 |
# File 'lib/natswork/monitoring.rb', line 243 def initialize @reporters = [] @enabled = true end |
Class Method Details
.global ⇒ Object
303 304 305 |
# File 'lib/natswork/monitoring.rb', line 303 def global @global ||= new end |
Instance Method Details
#add_reporter(reporter) ⇒ Object
248 249 250 |
# File 'lib/natswork/monitoring.rb', line 248 def add_reporter(reporter) @reporters << reporter end |
#disable! ⇒ Object
292 293 294 |
# File 'lib/natswork/monitoring.rb', line 292 def disable! @enabled = false end |
#enable! ⇒ Object
288 289 290 |
# File 'lib/natswork/monitoring.rb', line 288 def enable! @enabled = true end |
#remove_reporter(reporter) ⇒ Object
252 253 254 |
# File 'lib/natswork/monitoring.rb', line 252 def remove_reporter(reporter) @reporters.delete(reporter) end |
#report_counter(metric, value, tags = {}) ⇒ Object
256 257 258 259 260 261 262 |
# File 'lib/natswork/monitoring.rb', line 256 def report_counter(metric, value, = {}) return unless @enabled @reporters.each do |reporter| reporter.report_counter(metric, value, ) if reporter.respond_to?(:report_counter) end end |
#report_gauge(metric, value, tags = {}) ⇒ Object
264 265 266 267 268 269 270 |
# File 'lib/natswork/monitoring.rb', line 264 def report_gauge(metric, value, = {}) return unless @enabled @reporters.each do |reporter| reporter.report_gauge(metric, value, ) if reporter.respond_to?(:report_gauge) end end |
#report_histogram(metric, value, tags = {}) ⇒ Object
280 281 282 283 284 285 286 |
# File 'lib/natswork/monitoring.rb', line 280 def report_histogram(metric, value, = {}) return unless @enabled @reporters.each do |reporter| reporter.report_histogram(metric, value, ) if reporter.respond_to?(:report_histogram) end end |
#report_timer(metric, value, tags = {}) ⇒ Object
272 273 274 275 276 277 278 |
# File 'lib/natswork/monitoring.rb', line 272 def report_timer(metric, value, = {}) return unless @enabled @reporters.each do |reporter| reporter.report_timer(metric, value, ) if reporter.respond_to?(:report_timer) end end |
#shutdown ⇒ Object
296 297 298 299 300 |
# File 'lib/natswork/monitoring.rb', line 296 def shutdown @reporters.each do |reporter| reporter.close if reporter.respond_to?(:close) end end |