Class: LogStash::Instrument::NullMetric
- Inherits:
-
Object
- Object
- LogStash::Instrument::NullMetric
- Defined in:
- lib/logstash/instrument/null_metric.rb
Overview
This class is used in the context when we disable the metric collection for specific plugin to replace the ‘NamespacedMetric` class with this one which doesn’t produce any metric to the collector.
Defined Under Namespace
Classes: NullTimedExecution
Instance Attribute Summary collapse
-
#collector ⇒ Object
readonly
Returns the value of attribute collector.
-
#namespace_name ⇒ Object
readonly
Returns the value of attribute namespace_name.
Class Method Summary collapse
Instance Method Summary collapse
- #decrement(namespace, key, value = 1) ⇒ Object
- #gauge(namespace, key, value) ⇒ Object
- #increment(namespace, key, value = 1) ⇒ Object
-
#initialize(collector = nil) ⇒ NullMetric
constructor
A new instance of NullMetric.
- #namespace(name) ⇒ Object
- #report_time(namespace, key, duration) ⇒ Object
-
#time(namespace, key) ⇒ Object
We have to manually redefine this method since it can return an object this object also has to be implemented as a NullObject.
Constructor Details
#initialize(collector = nil) ⇒ NullMetric
Returns a new instance of NullMetric.
11 12 13 |
# File 'lib/logstash/instrument/null_metric.rb', line 11 def initialize(collector = nil) @collector = collector end |
Instance Attribute Details
#collector ⇒ Object (readonly)
Returns the value of attribute collector.
9 10 11 |
# File 'lib/logstash/instrument/null_metric.rb', line 9 def collector @collector end |
#namespace_name ⇒ Object (readonly)
Returns the value of attribute namespace_name.
9 10 11 |
# File 'lib/logstash/instrument/null_metric.rb', line 9 def namespace_name @namespace_name end |
Class Method Details
.validate_key!(key) ⇒ Object
47 48 49 |
# File 'lib/logstash/instrument/null_metric.rb', line 47 def self.validate_key!(key) raise MetricNoKeyProvided if key.nil? || key.empty? end |
Instance Method Details
#decrement(namespace, key, value = 1) ⇒ Object
19 20 21 |
# File 'lib/logstash/instrument/null_metric.rb', line 19 def decrement(namespace, key, value = 1) Metric.validate_key!(key) end |
#gauge(namespace, key, value) ⇒ Object
23 24 25 |
# File 'lib/logstash/instrument/null_metric.rb', line 23 def gauge(namespace, key, value) Metric.validate_key!(key) end |
#increment(namespace, key, value = 1) ⇒ Object
15 16 17 |
# File 'lib/logstash/instrument/null_metric.rb', line 15 def increment(namespace, key, value = 1) Metric.validate_key!(key) end |
#namespace(name) ⇒ Object
42 43 44 45 |
# File 'lib/logstash/instrument/null_metric.rb', line 42 def namespace(name) raise MetricNoNamespaceProvided if name.nil? || name.empty? NamespacedNullMetric.new(self, name) end |
#report_time(namespace, key, duration) ⇒ Object
27 28 29 |
# File 'lib/logstash/instrument/null_metric.rb', line 27 def report_time(namespace, key, duration) Metric.validate_key!(key) end |
#time(namespace, key) ⇒ Object
We have to manually redefine this method since it can return an object this object also has to be implemented as a NullObject
33 34 35 36 37 38 39 40 |
# File 'lib/logstash/instrument/null_metric.rb', line 33 def time(namespace, key) Metric.validate_key!(key) if block_given? yield else NullTimedExecution end end |