yabeda 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +15 -5
- data/lib/yabeda.rb +39 -0
- data/lib/yabeda/dsl/class_methods.rb +2 -1
- data/lib/yabeda/dsl/metric_builder.rb +0 -2
- data/lib/yabeda/errors.rb +15 -0
- data/lib/yabeda/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30e7d6e3fee4aac1922285af3fe9abc61cbfedff88ec2c2b95f70478383c02df
|
4
|
+
data.tar.gz: b5ff1691c1c692672b3d03fd46fc13f299d8851f61d3a65e1571389787b8b050
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b0872f973fe39a30be8c3c74f91e7c472aa246f7be08ed0d719c605b9ab42c7625b47c294dec04a15f82b4cc90984953b5658cc8041c51776ce3bb3ea70a1a9
|
7
|
+
data.tar.gz: 6ae9978212486a4deeefbb173cc7c103f5fa3a3f64db4c5ec21188a9a38aa94af39c741b900970ab5649d5ced0bf5979acd65bd531fdfa7b577640d85e7ab531
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## 0.4.0 - 2020-01-28
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- Configuration of gem was changed from synchronous (at the moment when `configure` block was executed) to postponed (only on `configure!` method call). [@Envek]
|
13
|
+
|
14
|
+
This should allow to fix problems when metrics from gems are registered too early, before required changes to the monitoring system clients.
|
15
|
+
|
8
16
|
## 0.3.0 - 2020-01-15
|
9
17
|
|
10
18
|
### Added
|
@@ -41,4 +49,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
41
49
|
|
42
50
|
- Initial release of evil-metrics gem. @Envek
|
43
51
|
|
52
|
+
[@Envek]: https://github.com/Envek "Andrey Novikov"
|
44
53
|
[@asusikov]: https://github.com/asusikov "Alexander Susikov"
|
data/README.md
CHANGED
@@ -43,7 +43,15 @@ And then execute:
|
|
43
43
|
end
|
44
44
|
```
|
45
45
|
|
46
|
-
2.
|
46
|
+
2. After your application was initialized and all metrics was declared, you need to apply Yabeda configuration:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
Yabeda.configure!
|
50
|
+
```
|
51
|
+
|
52
|
+
_But [yabeda-rails] will do this for you automatically._
|
53
|
+
|
54
|
+
3. Access metric in your app and use it!
|
47
55
|
|
48
56
|
```ruby
|
49
57
|
def ring_the_bell(id)
|
@@ -59,7 +67,7 @@ And then execute:
|
|
59
67
|
end
|
60
68
|
```
|
61
69
|
|
62
|
-
|
70
|
+
4. Setup collecting of metrics that do not tied to specific events in you application. E.g.: reporting your app's current state
|
63
71
|
```ruby
|
64
72
|
Yabeda.configure do
|
65
73
|
# This block will be executed periodically few times in a minute
|
@@ -71,15 +79,15 @@ And then execute:
|
|
71
79
|
end
|
72
80
|
```
|
73
81
|
|
74
|
-
|
82
|
+
5. _Optionally_ setup default tags that will be added to all metrics
|
75
83
|
```ruby
|
76
84
|
Yabeda.configure do
|
77
85
|
default_tag :rails_environment, 'production'
|
78
86
|
end
|
79
87
|
```
|
80
88
|
|
81
|
-
|
82
|
-
|
89
|
+
6. See the docs for the adapter you're using
|
90
|
+
7. Enjoy!
|
83
91
|
|
84
92
|
## Roadmap (aka TODO or Help wanted)
|
85
93
|
|
@@ -116,3 +124,5 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/yabeda
|
|
116
124
|
## License
|
117
125
|
|
118
126
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
127
|
+
|
128
|
+
[yabeda-rails]: https://github.com/yabeda-rb/yabeda-rails/ "Yabeda plugin for collecting and exporting basic metrics for Rails applications"
|
data/lib/yabeda.rb
CHANGED
@@ -5,6 +5,7 @@ require "concurrent"
|
|
5
5
|
require "yabeda/version"
|
6
6
|
require "yabeda/dsl"
|
7
7
|
require "yabeda/tags"
|
8
|
+
require "yabeda/errors"
|
8
9
|
|
9
10
|
# Extendable framework for collecting and exporting metrics from Ruby apps
|
10
11
|
module Yabeda
|
@@ -45,5 +46,43 @@ module Yabeda
|
|
45
46
|
instance.register!(metric)
|
46
47
|
end
|
47
48
|
end
|
49
|
+
|
50
|
+
# @return [Array<Proc>] All configuration blocks for postponed setup
|
51
|
+
def configurators
|
52
|
+
@configurators ||= Concurrent::Array.new
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [Boolean] Whether +Yabeda.configure!+ has been already called
|
56
|
+
def configured?
|
57
|
+
!@configured_by.nil?
|
58
|
+
end
|
59
|
+
alias already_configured? configured?
|
60
|
+
|
61
|
+
# Perform configuration: registration of metrics and collector blocks
|
62
|
+
# @return [void]
|
63
|
+
def configure!
|
64
|
+
raise(AlreadyConfiguredError, @configured_by) if already_configured?
|
65
|
+
|
66
|
+
configurators.each do |(group, block)|
|
67
|
+
group group
|
68
|
+
class_eval(&block)
|
69
|
+
group nil
|
70
|
+
end
|
71
|
+
|
72
|
+
@configured_by = caller_locations(1, 1)[0].to_s
|
73
|
+
end
|
74
|
+
|
75
|
+
# Forget all the configuration.
|
76
|
+
# For testing purposes as it doesn't rollback changes in adapters.
|
77
|
+
# @api private
|
78
|
+
def reset!
|
79
|
+
default_tags.clear
|
80
|
+
adapters.clear
|
81
|
+
groups.clear
|
82
|
+
metrics.clear
|
83
|
+
collectors.clear
|
84
|
+
configurators.clear
|
85
|
+
instance_variable_set(:@configured_by, nil)
|
86
|
+
end
|
48
87
|
end
|
49
88
|
end
|
@@ -14,7 +14,8 @@ module Yabeda
|
|
14
14
|
module ClassMethods
|
15
15
|
# Block for grouping and simplifying configuration of related metrics
|
16
16
|
def configure(&block)
|
17
|
-
|
17
|
+
Yabeda.configurators.push([@group, block])
|
18
|
+
class_exec(&block) if Yabeda.configured?
|
18
19
|
@group = nil
|
19
20
|
end
|
20
21
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Yabeda
|
4
|
+
class ConfigurationError < StandardError; end
|
5
|
+
|
6
|
+
# Raises on repeated call to +Yabeda.configure!+
|
7
|
+
class AlreadyConfiguredError < StandardError
|
8
|
+
def initialize(configuring_location)
|
9
|
+
super
|
10
|
+
@message = "Yabeda was already configured in #{configuring_location}"
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :message
|
14
|
+
end
|
15
|
+
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.4.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: 2020-01-
|
11
|
+
date: 2020-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -137,6 +137,7 @@ files:
|
|
137
137
|
- lib/yabeda/dsl/class_methods.rb
|
138
138
|
- lib/yabeda/dsl/metric_builder.rb
|
139
139
|
- lib/yabeda/dsl/option_builder.rb
|
140
|
+
- lib/yabeda/errors.rb
|
140
141
|
- lib/yabeda/gauge.rb
|
141
142
|
- lib/yabeda/group.rb
|
142
143
|
- lib/yabeda/histogram.rb
|