Class: LogStash::Instrument::NullMetric

Inherits:
Object
  • Object
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: NullTimedExecution

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#collectorObject (readonly)

Returns the value of attribute collector.



8
9
10
# File 'lib/logstash/instrument/null_metric.rb', line 8

def collector
  @collector
end

#namespace_nameObject (readonly)

Returns the value of attribute namespace_name.



8
9
10
# File 'lib/logstash/instrument/null_metric.rb', line 8

def namespace_name
  @namespace_name
end

Instance Method Details

#decrement(key, value = 1) ⇒ Object



13
14
# File 'lib/logstash/instrument/null_metric.rb', line 13

def decrement(key, value = 1)
end

#gauge(key, value) ⇒ Object



16
17
# File 'lib/logstash/instrument/null_metric.rb', line 16

def gauge(key, value)
end

#increment(key, value = 1) ⇒ Object



10
11
# File 'lib/logstash/instrument/null_metric.rb', line 10

def increment(key, value = 1)
end

#namespace(name) ⇒ Object



32
33
34
# File 'lib/logstash/instrument/null_metric.rb', line 32

def namespace(name)
  self.class.new
end

#report_time(key, duration) ⇒ Object



19
20
# File 'lib/logstash/instrument/null_metric.rb', line 19

def report_time(key, duration)
end

#time(key, &block) ⇒ Object

We have to manually redefine this method since it can return an object this object also has to be implemented as a NullObject



24
25
26
27
28
29
30
# File 'lib/logstash/instrument/null_metric.rb', line 24

def time(key, &block)
  if block_given?
    yield
  else
    NullTimedExecution
  end
end