Module: Yabeda
- Includes:
- DSL
- Defined in:
- lib/yabeda.rb,
lib/yabeda/dsl.rb,
lib/yabeda/tags.rb,
lib/yabeda/gauge.rb,
lib/yabeda/group.rb,
lib/yabeda/errors.rb,
lib/yabeda/metric.rb,
lib/yabeda/counter.rb,
lib/yabeda/railtie.rb,
lib/yabeda/version.rb,
lib/yabeda/histogram.rb,
lib/yabeda/base_adapter.rb,
lib/yabeda/dsl/class_methods.rb,
lib/yabeda/dsl/metric_builder.rb,
lib/yabeda/dsl/option_builder.rb
Overview
Extendable framework for collecting and exporting metrics from Ruby apps
Defined Under Namespace
Modules: DSL, Rails Classes: AlreadyConfiguredError, BaseAdapter, ConfigurationError, Counter, Gauge, Group, Histogram, Metric, Tags
Constant Summary collapse
- VERSION =
"0.8.0"
Class Method Summary collapse
-
.adapters ⇒ Hash<String, Yabeda::BaseAdapter>
All loaded adapters.
-
.collectors ⇒ Array<Proc>
All collectors for periodical retrieving of metrics.
-
.configurators ⇒ Array<Proc>
All configuration blocks for postponed setup.
-
.configure! ⇒ void
Perform configuration: registration of metrics and collector blocks rubocop: disable Metrics/MethodLength, Metrics/AbcSize.
-
.configured? ⇒ Boolean
(also: already_configured?)
Whether
Yabeda.configure!
has been already called. -
.default_tags ⇒ Hash<Symbol, Symbol>
All added default tags.
-
.groups ⇒ Hash<String, Yabeda::Group>
All registered metrics.
-
.metrics ⇒ Hash<String, Yabeda::Metric>
All registered metrics.
- .register_adapter(name, instance) ⇒ Object
-
.reset! ⇒ Object
private
Forget all the configuration.
Methods included from DSL
Class Method Details
.adapters ⇒ Hash<String, Yabeda::BaseAdapter>
Returns All loaded adapters.
27 28 29 |
# File 'lib/yabeda.rb', line 27 def adapters @adapters ||= Concurrent::Hash.new end |
.collectors ⇒ Array<Proc>
Returns All collectors for periodical retrieving of metrics.
32 33 34 |
# File 'lib/yabeda.rb', line 32 def collectors @collectors ||= Concurrent::Array.new end |
.configurators ⇒ Array<Proc>
Returns All configuration blocks for postponed setup.
52 53 54 |
# File 'lib/yabeda.rb', line 52 def configurators @configurators ||= Concurrent::Array.new end |
.configure! ⇒ void
This method returns an undefined value.
Perform configuration: registration of metrics and collector blocks rubocop: disable Metrics/MethodLength, Metrics/AbcSize
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/yabeda.rb', line 65 def configure! raise(AlreadyConfiguredError, @configured_by) if already_configured? configurators.each do |(group, block)| group group class_eval(&block) group nil end # Register metrics in adapters after evaluating all configuration blocks # to ensure that all global settings (like default tags) will be applied. adapters.each_value do |adapter| metrics.each_value do |metric| adapter.register!(metric) end end @configured_by = caller_locations(1, 1)[0].to_s end |
.configured? ⇒ Boolean Also known as: already_configured?
Returns Whether Yabeda.configure!
has been already called.
57 58 59 |
# File 'lib/yabeda.rb', line 57 def configured? !@configured_by.nil? end |
.default_tags ⇒ Hash<Symbol, Symbol>
Returns All added default tags.
37 38 39 |
# File 'lib/yabeda.rb', line 37 def @default_tags ||= Concurrent::Hash.new end |
.groups ⇒ Hash<String, Yabeda::Group>
Returns All registered metrics.
22 23 24 |
# File 'lib/yabeda.rb', line 22 def groups @groups ||= Concurrent::Hash.new end |
.metrics ⇒ Hash<String, Yabeda::Metric>
Returns All registered metrics.
17 18 19 |
# File 'lib/yabeda.rb', line 17 def metrics @metrics ||= Concurrent::Hash.new end |
.register_adapter(name, instance) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/yabeda.rb', line 43 def register_adapter(name, instance) adapters[name] = instance # NOTE: Pretty sure there is race condition metrics.each do |_, metric| instance.register!(metric) end end |
.reset! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Forget all the configuration. For testing purposes as it doesn’t rollback changes in adapters.
89 90 91 92 93 94 95 96 97 |
# File 'lib/yabeda.rb', line 89 def reset! .clear adapters.clear groups.clear metrics.clear collectors.clear configurators.clear instance_variable_set(:@configured_by, nil) end |