Class: LogStash::Instrument::NullMetric
- Inherits:
-
Object
- Object
- LogStash::Instrument::NullMetric
show all
- 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: NullGauge, NullTimedExecution
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
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
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
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
51
52
53
|
# File 'lib/logstash/instrument/null_metric.rb', line 51
def self.validate_key!(key)
raise MetricNoKeyProvided if key.nil? || key.empty?
end
|
Instance Method Details
#counter(_) ⇒ Object
42
43
44
|
# File 'lib/logstash/instrument/null_metric.rb', line 42
def counter(_)
NullGauge
end
|
#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
#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
|