yabeda 0.13.2 → 0.15.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/.github/workflows/test.yml +1 -0
- data/CHANGELOG.md +26 -0
- data/Gemfile +1 -2
- data/README.md +15 -0
- data/lib/yabeda/base_adapter.rb +7 -0
- data/lib/yabeda/counter.rb +2 -6
- data/lib/yabeda/dsl/class_methods.rb +17 -2
- data/lib/yabeda/gauge.rb +18 -3
- data/lib/yabeda/metric.rb +9 -5
- data/lib/yabeda/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4a403c359e0c88e79f3352df2521a880d17c2fee74457cd911e776d51042060f
|
|
4
|
+
data.tar.gz: 795a2312ba8de8ff41198444b87614fae3eb5fa803feed950f83d965c67f76a8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1e432f7754fcbe31703dca2f753e8c19552e7e941a7e9e064430cd34066fbfb8f714920af8a8c88c2b1deadeab4f6ec464b24bc466d413d2f819670d59d21a70
|
|
7
|
+
data.tar.gz: 88f8f047866dff1244fc5609586d2ec4560bae818c926fae2de5428c073ebc10655ea3997a163d9923f86ef63720614ea3b49236025a54f91c27673564c0f4d0
|
data/.github/workflows/test.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
7
7
|
|
|
8
8
|
## Unreleased
|
|
9
9
|
|
|
10
|
+
## 0.15.0 - 2026-03-04
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Concurrency issues with metrics' increment/decrement helper methods. [@cconstantine-onesignal][] in [#45](https://github.com/yabeda-rb/yabeda/pull/45)
|
|
15
|
+
|
|
16
|
+
## 0.14.0 - 2025-09-10
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- Allow to limit groups per adapter. [@killondark][] in [#41](https://github.com/yabeda-rb/yabeda/pull/41)
|
|
21
|
+
|
|
22
|
+
```ruby
|
|
23
|
+
Yabeda.configure do
|
|
24
|
+
group :mushrooms do
|
|
25
|
+
counter :champignon_counter
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
adapter :basket_adapter do
|
|
29
|
+
include_group :mushrooms
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
```
|
|
33
|
+
|
|
10
34
|
## 0.13.2 - 2025-09-09
|
|
11
35
|
|
|
12
36
|
### Fixed
|
|
@@ -196,3 +220,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
196
220
|
[@bibendi]: https://github.com/bibendi "Misha Merkushin"
|
|
197
221
|
[@Keallar]: https://github.com/Keallar "Eugene Lysanskiy"
|
|
198
222
|
[@jbockler]: https://github.com/jbockler "Josch Bockler"
|
|
223
|
+
[@killondark]: https://github.com/killondark "Alexander Marychev"
|
|
224
|
+
[@cconstantine-onesignal]: https://github.com/cconstantine-onesignal "Chris Constantine"
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -158,6 +158,8 @@ These are developed and maintained by other awesome folks:
|
|
|
158
158
|
- [yabeda-shoryuken](https://github.com/retsef/yabeda-shoryuken) — metrics for [Shoryuken](https://github.com/ruby-shoryuken/shoryuken) jobs execution message queues.
|
|
159
159
|
- [yabeda-rack-ratelimit](https://github.com/basecamp/yabeda-rack-ratelimit) — metrics for [Rack::Ratelimit](https://github.com/jeremy/rack-ratelimit)
|
|
160
160
|
- [yabeda-hanami](https://github.com/mlibrary/yabeda-hanami) — metrics for [Hanami](https://hanamirb.org/) The web, with simplicity.
|
|
161
|
+
- [yabeda-jemalloc](http://github.com/jondavidschober/yabeda-jemalloc) - metrics for [Jemalloc](https://jemalloc.net/) via the `stats` FFI
|
|
162
|
+
- [yabeda-rack-queue](https://github.com/speedshop/yabeda-rack-queue) - metrics for reporting queue times of Rack applications.
|
|
161
163
|
- _…and more! You can write your own adapter and open a pull request to add it into this list._
|
|
162
164
|
|
|
163
165
|
## Configuration
|
|
@@ -246,6 +248,19 @@ Yabeda.configure do
|
|
|
246
248
|
end
|
|
247
249
|
```
|
|
248
250
|
|
|
251
|
+
Or use another DSL to describe this logic:
|
|
252
|
+
|
|
253
|
+
```ruby
|
|
254
|
+
Yabeda.configure do
|
|
255
|
+
group :mushrooms do
|
|
256
|
+
counter :champignon_counter
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
adapter :basket_adapter do
|
|
260
|
+
include_group :mushrooms
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
```
|
|
249
264
|
|
|
250
265
|
## Roadmap (aka TODO or Help wanted)
|
|
251
266
|
|
data/lib/yabeda/base_adapter.rb
CHANGED
|
@@ -29,6 +29,13 @@ module Yabeda
|
|
|
29
29
|
raise NotImplementedError, "#{self.class} doesn't support setting gauges"
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
# Optional method that adapters can implement for native gauge increment/decrement
|
|
33
|
+
def perform_gauge_increment!(_gauge, _tags, _increment)
|
|
34
|
+
# used to indicate adapter does not implement this method. return a non-nil value
|
|
35
|
+
# in your adapter to indicate it is supported
|
|
36
|
+
nil
|
|
37
|
+
end
|
|
38
|
+
|
|
32
39
|
def register_histogram!(_metric)
|
|
33
40
|
raise NotImplementedError, "#{self.class} doesn't support histograms as metric type!"
|
|
34
41
|
end
|
data/lib/yabeda/counter.rb
CHANGED
|
@@ -10,15 +10,11 @@ module Yabeda
|
|
|
10
10
|
def increment(*args)
|
|
11
11
|
tags, by = self.class.parse_args(*args)
|
|
12
12
|
all_tags = ::Yabeda::Tags.build(tags, group)
|
|
13
|
-
|
|
13
|
+
value = increment_value(all_tags, by: by)
|
|
14
14
|
adapters.each_value do |adapter|
|
|
15
15
|
adapter.perform_counter_increment!(self, all_tags, by)
|
|
16
16
|
end
|
|
17
|
-
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def values
|
|
21
|
-
@values ||= Concurrent::Hash.new(0)
|
|
17
|
+
value
|
|
22
18
|
end
|
|
23
19
|
|
|
24
20
|
# @api private
|
|
@@ -96,10 +96,25 @@ module Yabeda
|
|
|
96
96
|
#
|
|
97
97
|
# @param adapter_names [Array<Symbol>] Names of adapters to use
|
|
98
98
|
def adapter(*adapter_names, group: @group)
|
|
99
|
-
raise ConfigurationError, "Adapter limitation can't be defined
|
|
99
|
+
raise ConfigurationError, "Adapter limitation can't be defined without adapter_names" if adapter_names.empty?
|
|
100
|
+
|
|
101
|
+
@adapter_names = adapter_names
|
|
102
|
+
if group
|
|
103
|
+
include_group(group)
|
|
104
|
+
else
|
|
105
|
+
return yield if block_given?
|
|
106
|
+
|
|
107
|
+
raise ConfigurationError, "Yabeda.adapter should be called either inside group declaration " \
|
|
108
|
+
"or should have block provided with a call to include_group. No metric group provided."
|
|
109
|
+
end
|
|
110
|
+
ensure @adapter_names = nil
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def include_group(group)
|
|
114
|
+
raise ConfigurationError, "Adapter limitation can't be defined without of group name" unless group
|
|
100
115
|
|
|
101
116
|
Yabeda.groups[group] ||= Yabeda::Group.new(group)
|
|
102
|
-
Yabeda.groups[group].adapter(
|
|
117
|
+
Yabeda.groups[group].adapter(*@adapter_names)
|
|
103
118
|
end
|
|
104
119
|
|
|
105
120
|
private
|
data/lib/yabeda/gauge.rb
CHANGED
|
@@ -5,7 +5,8 @@ module Yabeda
|
|
|
5
5
|
class Gauge < Metric
|
|
6
6
|
def set(tags, value)
|
|
7
7
|
all_tags = ::Yabeda::Tags.build(tags, group)
|
|
8
|
-
values[all_tags]
|
|
8
|
+
atomic_value = values[all_tags] ||= Concurrent::Atom.new(0)
|
|
9
|
+
atomic_value.swap { |_| value }
|
|
9
10
|
adapters.each_value do |adapter|
|
|
10
11
|
adapter.perform_gauge_set!(self, all_tags, value)
|
|
11
12
|
end
|
|
@@ -18,7 +19,14 @@ module Yabeda
|
|
|
18
19
|
# @param by [Integer] increment value
|
|
19
20
|
def increment(*args)
|
|
20
21
|
tags, by = Counter.parse_args(*args)
|
|
21
|
-
|
|
22
|
+
all_tags = ::Yabeda::Tags.build(tags, group)
|
|
23
|
+
next_value = increment_value(all_tags, by: by)
|
|
24
|
+
adapters.each_value do |adapter|
|
|
25
|
+
if adapter.perform_gauge_increment!(self, all_tags, by).nil?
|
|
26
|
+
adapter.perform_gauge_set!(self, all_tags, next_value)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
next_value
|
|
22
30
|
end
|
|
23
31
|
|
|
24
32
|
# @overload decrement(tags = {}, by: 1)
|
|
@@ -27,7 +35,14 @@ module Yabeda
|
|
|
27
35
|
# @param by [Integer] decrement value
|
|
28
36
|
def decrement(*args)
|
|
29
37
|
tags, by = Counter.parse_args(*args)
|
|
30
|
-
|
|
38
|
+
all_tags = ::Yabeda::Tags.build(tags, group)
|
|
39
|
+
next_value = increment_value(all_tags, by: -by)
|
|
40
|
+
adapters.each_value do |adapter|
|
|
41
|
+
if adapter.perform_gauge_increment!(self, all_tags, -by).nil?
|
|
42
|
+
adapter.perform_gauge_set!(self, all_tags, next_value)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
next_value
|
|
31
46
|
end
|
|
32
47
|
end
|
|
33
48
|
end
|
data/lib/yabeda/metric.rb
CHANGED
|
@@ -17,14 +17,11 @@ module Yabeda
|
|
|
17
17
|
# rubocop:disable Layout/LineLength
|
|
18
18
|
option :adapter, optional: true, comment: "Monitoring system adapter to register metric in and report metric values to (other adapters won't be used)"
|
|
19
19
|
# rubocop:enable Layout/LineLength
|
|
20
|
+
option :values, optional: true, default: proc { Concurrent::Hash.new }
|
|
20
21
|
|
|
21
22
|
# Returns the value for the given label set
|
|
22
23
|
def get(labels = {})
|
|
23
|
-
values[::Yabeda::Tags.build(labels, group)]
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def values
|
|
27
|
-
@values ||= Concurrent::Hash.new
|
|
24
|
+
@values[::Yabeda::Tags.build(labels, group)]&.value
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
# Returns allowed tags for metric (with account for global and group-level +default_tags+)
|
|
@@ -62,5 +59,12 @@ module Yabeda
|
|
|
62
59
|
|
|
63
60
|
super
|
|
64
61
|
end
|
|
62
|
+
|
|
63
|
+
# Atomically increment the stored value, assumed to be given all labels, including group labels
|
|
64
|
+
# @api private
|
|
65
|
+
def increment_value(labels = {}, by: 1)
|
|
66
|
+
atomic_value = values[labels] ||= Concurrent::Atom.new(0)
|
|
67
|
+
atomic_value.swap { |prev| prev + by }
|
|
68
|
+
end
|
|
65
69
|
end
|
|
66
70
|
end
|
data/lib/yabeda/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yabeda
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.15.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrey Novikov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-03-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: anyway_config
|