Class: AceMQ::AMQP::Telemetry::Reporter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/acemq/amqp/telemetry.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Reports to an observer without letting the observer break anything.

Everything in the library goes through one of these rather than calling an observer directly. A metrics backend that is full, slow or misconfigured is a problem for whoever runs the metrics; turning it into undelivered messages would make observability the thing that caused the outage.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(observer) ⇒ Reporter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Reporter.



499
500
501
# File 'lib/acemq/amqp/telemetry.rb', line 499

def initialize(observer)
  @observer = observer || None.new
end

Instance Attribute Details

#observer ⇒ Object (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The observer underneath, for a caller that wants to read its numbers.



504
505
506
# File 'lib/acemq/amqp/telemetry.rb', line 504

def observer
  @observer
end

Class Method Details

.for(observer) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Wraps an observer, or hands back one that is already wrapped.

A connection wraps once and passes the wrapper to its consumers, and this is what keeps a consumer from wrapping the wrapper — which would work, and would swallow an observer's failure twice while reporting it under the wrong name.



497
# File 'lib/acemq/amqp/telemetry.rb', line 497

def self.for(observer) = observer.is_a?(Reporter) ? observer : new(observer)

Instance Method Details

#count(metric, delta = 1, **labels) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



506
507
508
509
510
# File 'lib/acemq/amqp/telemetry.rb', line 506

def count(metric, delta = 1, **labels)
  @observer.count(metric, delta, **labels)
rescue StandardError => e
  complain(metric, e)
end

#gauge(metric, value, **labels) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



518
519
520
521
522
# File 'lib/acemq/amqp/telemetry.rb', line 518

def gauge(metric, value, **labels)
  @observer.gauge(metric, value, **labels)
rescue StandardError => e
  complain(metric, e)
end

#observe(metric, value, **labels) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



512
513
514
515
516
# File 'lib/acemq/amqp/telemetry.rb', line 512

def observe(metric, value, **labels)
  @observer.observe(metric, value, **labels)
rescue StandardError => e
  complain(metric, e)
end