Class: AceMQ::AMQP::Telemetry::Reporter Private
- Inherits:
-
Object
- Object
- AceMQ::AMQP::Telemetry::Reporter
- 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
-
#observer ⇒ Object
readonly
private
The observer underneath, for a caller that wants to read its numbers.
Class Method Summary collapse
-
.for(observer) ⇒ Object
private
Wraps an observer, or hands back one that is already wrapped.
Instance Method Summary collapse
- #count(metric, delta = 1, **labels) ⇒ Object private
- #gauge(metric, value, **labels) ⇒ Object private
-
#initialize(observer) ⇒ Reporter
constructor
private
A new instance of Reporter.
- #observe(metric, value, **labels) ⇒ Object private
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.
502 503 504 |
# File 'lib/acemq/amqp/telemetry.rb', line 502 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.
507 508 509 |
# File 'lib/acemq/amqp/telemetry.rb', line 507 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.
500 |
# File 'lib/acemq/amqp/telemetry.rb', line 500 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.
509 510 511 512 513 |
# File 'lib/acemq/amqp/telemetry.rb', line 509 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.
521 522 523 524 525 |
# File 'lib/acemq/amqp/telemetry.rb', line 521 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.
515 516 517 518 519 |
# File 'lib/acemq/amqp/telemetry.rb', line 515 def observe(metric, value, **labels) @observer.observe(metric, value, **labels) rescue StandardError => e complain(metric, e) end |