Class: LogStash::Instrument::NamespacedMetric

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/instrument/namespaced_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, namespace_name) ⇒ NamespacedMetric

Create metric with a specific namespace

Parameters:



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

def initialize(metric, namespace_name)
  @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_metric.rb', line 13

def namespace_name
  @namespace_name
end

Instance Method Details

#collectorObject



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

def collector
  @metric.collector
end

#decrement(key, value = 1) ⇒ Object



27
28
29
# File 'lib/logstash/instrument/namespaced_metric.rb', line 27

def decrement(key, value = 1)
  @metric.decrement(namespace_name, key, value)
end

#gauge(key, value) ⇒ Object



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

def gauge(key, value)
  @metric.gauge(namespace_name, key, value)
end

#increment(key, value = 1) ⇒ Object



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

def increment(key, value = 1)
  @metric.increment(namespace_name, key, value)
end

#namespace(name) ⇒ Object



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

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

#report_time(key, duration) ⇒ Object



35
36
37
# File 'lib/logstash/instrument/namespaced_metric.rb', line 35

def report_time(key, duration)
  @metric.report_time(namespace_name, key, duration)
end

#time(key, &block) ⇒ Object



39
40
41
# File 'lib/logstash/instrument/namespaced_metric.rb', line 39

def time(key, &block)
  @metric.time(namespace_name, key, &block)
end