Class: LogStash::Instrument::NamespacedNullMetric

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/instrument/namespaced_null_metric.rb

Overview

This class acts a a proxy between the metric library and the user calls.

This is the class that plugins authors will use to interact with the ‘MetricStore` It has the same public interface as `Metric` class but doesnt require to send the namespace on every call.

See Also:

  • Logstash::Instrument::Metric

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metric = nil, namespace_name = :null) ⇒ NamespacedNullMetric

Create metric with a specific namespace

Parameters:



18
19
20
21
# File 'lib/logstash/instrument/namespaced_null_metric.rb', line 18

def initialize(metric = nil, namespace_name = :null)
  @metric = metric
  @namespace_name = Array(namespace_name)
end

Instance Attribute Details

#namespace_nameObject (readonly)

Returns the value of attribute namespace_name.



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

def namespace_name
  @namespace_name
end

Instance Method Details

#collectorObject



43
44
45
# File 'lib/logstash/instrument/namespaced_null_metric.rb', line 43

def collector
  @metric.collector
end

#counter(_) ⇒ Object



47
48
49
# File 'lib/logstash/instrument/namespaced_null_metric.rb', line 47

def counter(_)
  ::LogStash::Instrument::NullMetric::NullGauge
end

#decrement(key, value = 1) ⇒ Object



26
27
# File 'lib/logstash/instrument/namespaced_null_metric.rb', line 26

def decrement(key, value = 1)
end

#gauge(key, value) ⇒ Object



29
30
# File 'lib/logstash/instrument/namespaced_null_metric.rb', line 29

def gauge(key, value)
end

#increment(key, value = 1) ⇒ Object



23
24
# File 'lib/logstash/instrument/namespaced_null_metric.rb', line 23

def increment(key, value = 1)
end

#namespace(name) ⇒ Object



51
52
53
# File 'lib/logstash/instrument/namespaced_null_metric.rb', line 51

def namespace(name)
  NamespacedNullMetric.new(metric, namespace_name + Array(name))
end

#report_time(key, duration) ⇒ Object



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

def report_time(key, duration)
end

#time(key, &block) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/logstash/instrument/namespaced_null_metric.rb', line 35

def time(key, &block)
  if block_given?
    yield
  else
    ::LogStash::Instrument::NullMetric::NullTimedExecution
  end
end