Class: Yabeda::Kafka::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/yabeda/kafka/proxy.rb

Defined Under Namespace

Classes: Counter, Gauge, Histogram

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(group) ⇒ Proxy

Returns a new instance of Proxy.



8
9
10
11
# File 'lib/yabeda/kafka/proxy.rb', line 8

def initialize(group)
  @group = group
  @metrics = []
end

Instance Attribute Details

#groupObject (readonly)

Returns the value of attribute group.



6
7
8
# File 'lib/yabeda/kafka/proxy.rb', line 6

def group
  @group
end

#metricsObject (readonly)

Returns the value of attribute metrics.



6
7
8
# File 'lib/yabeda/kafka/proxy.rb', line 6

def metrics
  @metrics
end

Instance Method Details

#counter(name, docstring:, labels:) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/yabeda/kafka/proxy.rb', line 13

def counter(name, docstring:, labels:)
  metrics.push name

  ::Yabeda::Kafka::Proxy::Counter.new(
    group.counter(name, comment: docstring, tags: labels)
  )
end

#gauge(name, docstring:, labels:) ⇒ Object



34
35
36
37
38
39
# File 'lib/yabeda/kafka/proxy.rb', line 34

def gauge(name, docstring:, labels:)
  metrics.push name
  ::Yabeda::Kafka::Proxy::Gauge.new(
    group.gauge(name, tags: labels, comment: docstring)
  )
end

#histogram(name, docstring:, labels:, buckets: nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/yabeda/kafka/proxy.rb', line 21

def histogram(name, docstring:, labels:, buckets: nil)
  metrics.push name

  ::Yabeda::Kafka::Proxy::Histogram.new(
    group.histogram(
      name,
      comment: docstring,
      tags: labels,
      buckets: buckets
    )
  )
end