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
40
41
42
|
# File 'lib/prometheus/client/registry.rb', line 40
def counter(name, docstring, base_labels = {})
register(Counter.new(name, docstring, base_labels))
end
|
#exist?(name) ⇒ Boolean
57
58
59
|
# File 'lib/prometheus/client/registry.rb', line 57
def exist?(name)
@metrics.key?(name)
end
|
#gauge(name, docstring, base_labels = {}) ⇒ Object
48
49
50
|
# File 'lib/prometheus/client/registry.rb', line 48
def gauge(name, docstring, base_labels = {})
register(Gauge.new(name, docstring, base_labels))
end
|
#get(name) ⇒ Object
61
62
63
|
# File 'lib/prometheus/client/registry.rb', line 61
def get(name)
@metrics[name.to_sym]
end
|
#histogram(name, docstring, base_labels = {}, buckets = Histogram::DEFAULT_BUCKETS) ⇒ Object
52
53
54
55
|
# File 'lib/prometheus/client/registry.rb', line 52
def histogram(name, docstring, base_labels = {},
buckets = Histogram::DEFAULT_BUCKETS)
register(Histogram.new(name, docstring, base_labels, buckets))
end
|
#metrics ⇒ Object
65
66
67
|
# File 'lib/prometheus/client/registry.rb', line 65
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
44
45
46
|
# File 'lib/prometheus/client/registry.rb', line 44
def summary(name, docstring, base_labels = {})
register(Summary.new(name, docstring, base_labels))
end
|
#unregister(name) ⇒ Object
34
35
36
37
38
|
# File 'lib/prometheus/client/registry.rb', line 34
def unregister(name)
@mutex.synchronize do
@metrics.delete(name.to_sym)
end
end
|