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
-
#counter(name, docstring:, labels: [], preset_labels: {}, store_settings: {}) ⇒ Object
-
#exist?(name) ⇒ Boolean
-
#gauge(name, docstring:, labels: [], preset_labels: {}, store_settings: {}) ⇒ Object
-
#get(name) ⇒ Object
-
#histogram(name, docstring:, labels: [], preset_labels: {}, buckets: Histogram::DEFAULT_BUCKETS, store_settings: {}) ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
-
#metrics ⇒ Object
-
#register(metric) ⇒ Object
-
#summary(name, docstring:, labels: [], preset_labels: {}, store_settings: {}) ⇒ Object
-
#unregister(name) ⇒ Object
-
#vm_histogram(name, docstring:, labels: [], preset_labels: {}, buckets: [], store_settings: {}) ⇒ Object
Constructor Details
Returns a new instance of Registry.
17
18
19
20
|
# File 'lib/prometheus/client/registry.rb', line 17
def initialize
@metrics = {}
@mutex = Mutex.new
end
|
Instance Method Details
#counter(name, docstring:, labels: [], preset_labels: {}, store_settings: {}) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/prometheus/client/registry.rb', line 41
def counter(name, docstring:, labels: [], preset_labels: {}, store_settings: {})
register(Counter.new(name,
docstring: docstring,
labels: labels,
preset_labels: preset_labels,
store_settings: store_settings))
end
|
#exist?(name) ⇒ Boolean
87
88
89
|
# File 'lib/prometheus/client/registry.rb', line 87
def exist?(name)
@mutex.synchronize { @metrics.key?(name) }
end
|
#gauge(name, docstring:, labels: [], preset_labels: {}, store_settings: {}) ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/prometheus/client/registry.rb', line 57
def gauge(name, docstring:, labels: [], preset_labels: {}, store_settings: {})
register(Gauge.new(name,
docstring: docstring,
labels: labels,
preset_labels: preset_labels,
store_settings: store_settings))
end
|
#get(name) ⇒ Object
91
92
93
|
# File 'lib/prometheus/client/registry.rb', line 91
def get(name)
@mutex.synchronize { @metrics[name.to_sym] }
end
|
#histogram(name, docstring:, labels: [], preset_labels: {}, buckets: Histogram::DEFAULT_BUCKETS, store_settings: {}) ⇒ Object
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/prometheus/client/registry.rb', line 65
def histogram(name, docstring:, labels: [], preset_labels: {},
buckets: Histogram::DEFAULT_BUCKETS,
store_settings: {})
register(Histogram.new(name,
docstring: docstring,
labels: labels,
preset_labels: preset_labels,
buckets: buckets,
store_settings: store_settings))
end
|
#metrics ⇒ Object
95
96
97
|
# File 'lib/prometheus/client/registry.rb', line 95
def metrics
@mutex.synchronize { @metrics.values }
end
|
#register(metric) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/prometheus/client/registry.rb', line 22
def register(metric)
name = metric.name
@mutex.synchronize do
if @metrics.key?(name.to_sym)
raise AlreadyRegisteredError, "#{name} has already been registered"
end
@metrics[name.to_sym] = metric
end
metric
end
|
#summary(name, docstring:, labels: [], preset_labels: {}, store_settings: {}) ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/prometheus/client/registry.rb', line 49
def summary(name, docstring:, labels: [], preset_labels: {}, store_settings: {})
register(Summary.new(name,
docstring: docstring,
labels: labels,
preset_labels: preset_labels,
store_settings: store_settings))
end
|
#unregister(name) ⇒ Object
35
36
37
38
39
|
# File 'lib/prometheus/client/registry.rb', line 35
def unregister(name)
@mutex.synchronize do
@metrics.delete(name.to_sym)
end
end
|
#vm_histogram(name, docstring:, labels: [], preset_labels: {}, buckets: [], store_settings: {}) ⇒ Object
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/prometheus/client/registry.rb', line 76
def vm_histogram(name, docstring:, labels: [], preset_labels: {},
buckets: [],
store_settings: {})
register(VmHistogram.new(name,
docstring: docstring,
labels: labels,
preset_labels: preset_labels,
buckets: buckets,
store_settings: store_settings))
end
|