Class: Prometheus::Client::Registry
- Inherits:
-
Object
- Object
- Prometheus::Client::Registry
show all
- Defined in:
- lib/prometheus/client/registry.rb
Overview
Defined Under Namespace
Classes: AlreadyRegisteredError
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Registry.
16
17
18
19
|
# File 'lib/prometheus/client/registry.rb', line 16
def initialize
@metrics = {}
@mutex = Mutex.new
end
|
Instance Method Details
#counter(name, docstring, base_labels = {}) ⇒ Object
34
35
36
|
# File 'lib/prometheus/client/registry.rb', line 34
def counter(name, docstring, base_labels = {})
register(Counter.new(name, docstring, base_labels))
end
|
#exist?(name) ⇒ Boolean
51
52
53
|
# File 'lib/prometheus/client/registry.rb', line 51
def exist?(name)
@metrics.key?(name)
end
|
#gauge(name, docstring, base_labels = {}) ⇒ Object
42
43
44
|
# File 'lib/prometheus/client/registry.rb', line 42
def gauge(name, docstring, base_labels = {})
register(Gauge.new(name, docstring, base_labels))
end
|
#get(name) ⇒ Object
55
56
57
|
# File 'lib/prometheus/client/registry.rb', line 55
def get(name)
@metrics[name.to_sym]
end
|
#histogram(name, docstring, base_labels = {}, buckets = Histogram::DEFAULT_BUCKETS) ⇒ Object
46
47
48
49
|
# File 'lib/prometheus/client/registry.rb', line 46
def histogram(name, docstring, base_labels = {},
buckets = Histogram::DEFAULT_BUCKETS)
register(Histogram.new(name, docstring, base_labels, buckets))
end
|
#metrics ⇒ Object
59
60
61
|
# File 'lib/prometheus/client/registry.rb', line 59
def metrics
@metrics.values
end
|
#register(metric) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/prometheus/client/registry.rb', line 21
def register(metric)
name = metric.name
@mutex.synchronize do
if exist?(name.to_sym)
raise AlreadyRegisteredError, "#{name} has already been registered"
end
@metrics[name.to_sym] = metric
end
metric
end
|
#summary(name, docstring, base_labels = {}) ⇒ Object
38
39
40
|
# File 'lib/prometheus/client/registry.rb', line 38
def summary(name, docstring, base_labels = {})
register(Summary.new(name, docstring, base_labels))
end
|