yabeda 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8303dda88bd4a759800248c44901f651992a8d38a0d75bf1d974b169a0e3020a
4
- data.tar.gz: 53247638e8aa2697ceac88c70ff6155490a6dbcda5550feee1d5243e12280085
3
+ metadata.gz: 7c30404230f234aefbf4f0f8341f276583b30f5cc9a75495e5c57e8acab23187
4
+ data.tar.gz: 980db126d071f8fe8c879798bbe35d5755819dd0384770dae7fe19d940f09840
5
5
  SHA512:
6
- metadata.gz: a4a8044919d940c2d1c4f4b779303e6424d68224aae578660cdd932630a57de4f4f41bd03b9f40aa1f285ecff0c09f1c6c760597ffe04f8a1a38d8e2e28c5f9a
7
- data.tar.gz: 11d0aadd135fa73fa60d9764cc518abf0966b0d44d1f607ed4244e79d1166792d4de9c9857bcfc7ec62b1641f3b843a4b0fb63de02932c9eea1fb8a1435a408b
6
+ metadata.gz: 20bf75e05040cc0ea26035422a4a64a5856ba683c0b98c81b756cc39311e41488972a57fca6174554d2d5175d85b7c5e59f5bd2375627cfb3756155cb31423ee
7
+ data.tar.gz: df6d12199c647f43858d0b6f73cd09ce1f7ab62b00190f251a7e37cbb17257b682fc844bbd65a03816c6c007e5757aef444637fcf410b65809dcccc96ae1a17a
data/.rubocop.yml CHANGED
@@ -10,6 +10,9 @@ Metrics/BlockLength:
10
10
  - "Gemfile"
11
11
  - "spec/**/*"
12
12
 
13
+ Metrics/LineLength:
14
+ Max: 120
15
+
13
16
  Style/BracesAroundHashParameters:
14
17
  EnforcedStyle: context_dependent
15
18
 
data/.travis.yml CHANGED
@@ -3,7 +3,7 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.5.1
7
- - 2.4.4
8
- - 2.3.7
9
- before_install: gem install bundler -v 1.16.5
6
+ - 2.5.3
7
+ - 2.4.5
8
+ - 2.3.8
9
+ before_install: gem install bundler -v 1.17.0
data/README.md CHANGED
@@ -1,8 +1,16 @@
1
1
  # Yabeda
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/yabeda.svg)](https://rubygems.org/gems/yabeda) [![Build Status](https://travis-ci.org/yabeda-rb/yabeda.svg?branch=master)](https://travis-ci.org/yabeda-rb/yabeda)
4
+
3
5
  **This software is Work in Progress: features will appear and disappear, API will be changed, your feedback is always welcome!**
4
6
 
5
- Extensible solution for easy setup of monitoring in your Ruby apps.
7
+ Extendable solution for easy setup of monitoring in your Ruby apps.
8
+
9
+ <a href="https://evilmartians.com/?utm_source=yabeda&utm_campaign=project_page">
10
+ <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54">
11
+ </a>
12
+
13
+ > Read more about Yabeda and the reasoning behind it in Martian Chronicles: [“Meet Yabeda: Modular framework for instrumenting Ruby applications”](https://evilmartians.com/chronicles/meet-yabeda-modular-framework-for-instrumenting-ruby-applications)
6
14
 
7
15
  ## Installation
8
16
 
data/Rakefile CHANGED
@@ -2,7 +2,10 @@
2
2
 
3
3
  require "bundler/gem_tasks"
4
4
  require "rspec/core/rake_task"
5
+ require "rubocop/rake_task"
6
+
7
+ RuboCop::RakeTask.new
5
8
 
6
9
  RSpec::Core::RakeTask.new(:spec)
7
10
 
8
- task default: :spec
11
+ task default: %i[rubocop spec]
data/lib/yabeda.rb CHANGED
@@ -5,14 +5,26 @@ require "concurrent"
5
5
  require "yabeda/version"
6
6
  require "yabeda/dsl"
7
7
 
8
+ # Extendable framework for collecting and exporting metrics from Ruby apps
8
9
  module Yabeda
9
10
  include DSL
10
11
 
11
- cattr_reader :metrics, default: Concurrent::Hash.new
12
- cattr_reader :adapters, default: Concurrent::Hash.new
13
- cattr_reader :collectors, default: Concurrent::Array.new
14
-
15
12
  class << self
13
+ # @return [Hash<String, Yabeda::Metric>] All registered metrics
14
+ def metrics
15
+ @metrics ||= Concurrent::Hash.new
16
+ end
17
+
18
+ # @return [Hash<String, Yabeda::BaseAdapter>] All loaded adapters
19
+ def adapters
20
+ @adapters ||= Concurrent::Hash.new
21
+ end
22
+
23
+ # @return [Array<Proc>] All collectors for periodical retrieving of metrics
24
+ def collectors
25
+ @collectors ||= Concurrent::Array.new
26
+ end
27
+
16
28
  # @param [Symbol] name
17
29
  # @param [BaseAdapter] instance
18
30
  def register_adapter(name, instance)
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Yabeda
4
+ # Base class for adapters to particular monitoring systems
4
5
  class BaseAdapter
5
6
  def register!(metric)
6
7
  case metric
data/lib/yabeda/dsl.rb CHANGED
@@ -6,33 +6,44 @@ require "yabeda/gauge"
6
6
  require "yabeda/histogram"
7
7
 
8
8
  module Yabeda
9
+ # DSL for ease of work with Yabeda
9
10
  module DSL
10
11
  def self.included(base)
11
12
  base.extend ClassMethods
12
13
  end
13
14
 
15
+ # rubocop: disable Style/Documentation
14
16
  module ClassMethods
17
+ # Block for grouping and simplifying configuration of related metrics
15
18
  def configure(&block)
16
19
  class_exec(&block)
17
20
  @group = nil
18
21
  end
19
22
 
23
+ # Define the actions that should be performed
20
24
  def collect(&block)
21
25
  ::Yabeda.collectors.push(block)
22
26
  end
23
27
 
28
+ # Specify metric category or group for all consecutive metrics in this
29
+ # +configure+ block.
30
+ # On most adapters it is only adds prefix to the metric name but on some
31
+ # (like NewRelic) it is treated individually and have special meaning.
24
32
  def group(group_name)
25
33
  @group = group_name
26
34
  end
27
35
 
36
+ # Register a growing-only counter
28
37
  def counter(*args, **kwargs)
29
38
  register(Counter.new(*args, **kwargs, group: @group))
30
39
  end
31
40
 
41
+ # Register a gauge
32
42
  def gauge(*args, **kwargs)
33
43
  register(Gauge.new(*args, **kwargs, group: @group))
34
44
  end
35
45
 
46
+ # Register an histogram
36
47
  def histogram(*args, **kwargs)
37
48
  register(Histogram.new(*args, **kwargs, group: @group))
38
49
  end
@@ -49,5 +60,6 @@ module Yabeda
49
60
  metric
50
61
  end
51
62
  end
63
+ # rubocop: enable Style/Documentation
52
64
  end
53
65
  end
data/lib/yabeda/gauge.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Yabeda
4
- # Arbitrary value
4
+ # Arbitrary value, can be changed in both sides
5
5
  class Gauge < Metric
6
6
  def set(tags, value)
7
7
  values[tags] = value
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Yabeda
4
+ # Base class for complex metric for measuring time values that allow to
5
+ # calculate averages, percentiles, and so on.
4
6
  class Histogram < Metric
5
7
  option :buckets
6
8
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Yabeda
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
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.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Novikov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-17 00:00:00.000000000 Z
11
+ date: 2018-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby