gitlab-labkit 0.38.2 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/labkit/metrics/README.md +5 -2
- data/lib/labkit/metrics/client.rb +5 -1
- data/lib/labkit/metrics/registry.rb +9 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 639ab73c3db48ed9078b0ae3743b5031d3d3e89dfde6aff9c65818b9aece82cb
|
4
|
+
data.tar.gz: ab65ac7320604017406ea64242c9dba98665ed12ad0f1268820e75031c301452
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14feead5381e4d99a08cac69768dace5080d394c7267cc4c90fc44d0b5839b24838a16469e627f086a2731ac972f38729cb28cec96e84c2ac0ba5d1c27cc4eeb
|
7
|
+
data.tar.gz: aaae5ce7dbd8454862ce64a93a73280931802575213cfe18c35dee3a7edb410a240937da508b30c2cabe5dbefb0e3e534cbbd2c5a1428dcc2b6b8e90110392d8
|
@@ -3,13 +3,16 @@
|
|
3
3
|
## Usage
|
4
4
|
|
5
5
|
```ruby
|
6
|
-
# create a new counter metric
|
6
|
+
# create a new counter metric and returns it
|
7
7
|
http_requests = Labkit::Metrics::Client.counter(:http_requests, 'A counter of HTTP requests made')
|
8
8
|
# start using the counter
|
9
9
|
http_requests.increment
|
10
10
|
|
11
|
-
# resets the registry and reinitializes all metrics files
|
11
|
+
# resets the registry and reinitializes all metrics files
|
12
12
|
Labkit::Metrics::Client.reset!
|
13
|
+
|
14
|
+
# retrieves the metric (be it a counter, gauge, histogram, summary)
|
15
|
+
http_requests = Labkit::Metrics::Client.get(:http_requests)
|
13
16
|
```
|
14
17
|
|
15
18
|
### Counter
|
@@ -72,12 +72,16 @@ module Labkit
|
|
72
72
|
Registry.reset!
|
73
73
|
end
|
74
74
|
|
75
|
+
def get(metric_name)
|
76
|
+
Registry.get(metric_name)
|
77
|
+
end
|
78
|
+
|
75
79
|
class << self
|
76
80
|
extend Forwardable
|
77
81
|
|
78
82
|
def_delegators :instance,
|
79
83
|
:enable!, :disable!, :counter, :gauge, :histogram, :summary, :reset!, :enabled?,
|
80
|
-
:configure, :reinitialize_on_pid_change, :configuration
|
84
|
+
:configure, :reinitialize_on_pid_change, :configuration, :get
|
81
85
|
|
82
86
|
private :instance
|
83
87
|
end
|
@@ -30,7 +30,7 @@ module Labkit
|
|
30
30
|
# counter = Registry.safe_register(:counter, :http_requests_total, 'Total HTTP requests')
|
31
31
|
def safe_register(metric_type, name, *args)
|
32
32
|
REGISTER_MUTEX.synchronize do
|
33
|
-
|
33
|
+
get(name) || wrapped_registry.method(metric_type).call(name, *args)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -43,6 +43,14 @@ module Labkit
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
# Returns the metric for the given name from the Prometheus registry.
|
47
|
+
#
|
48
|
+
# @param metric_name [Symbol, String] The name of the metric
|
49
|
+
# @return [Prometheus::Client::Metric, nil] The registered metric or nil if it does not exist
|
50
|
+
def get(metric_name)
|
51
|
+
wrapped_registry.get(metric_name)
|
52
|
+
end
|
53
|
+
|
46
54
|
private
|
47
55
|
|
48
56
|
def wrapped_registry
|