yabeda 0.5.0 → 0.6.0

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: 324b1326a709ae2ef5754ab07f117a6f7ee801df3f35c0c973198e85c6e7c1b1
4
- data.tar.gz: b06be1f053df8d40fa31a3cd0f84ecc52ea7f0fc59c72bf1d13f938862dc16dd
3
+ metadata.gz: 44b181b32e9a07ba7095d67d782e85587fd76280dae1ac5e0feb0a2e5c6ed2c4
4
+ data.tar.gz: 7c21877d04cc6e5284934619e22e47b75047000c9b1ccb6a936f07d4f5db6fb2
5
5
  SHA512:
6
- metadata.gz: 61a38c13f05a2357c1dee89891e6738675be94c587fd271950584aa14e581ab49cf87fe27d023b39290357763fed11e8d22f53a6e39930a4d8e0f7959f420cc7
7
- data.tar.gz: e5c8f67eed9e8c2e46d8ae6367c12ea287a39eadd75985e78942da285ea8e2ec8d73ea73c54b04c9efe7eb0215ffcff48c0c60fe0fa61c4ca50b134e024fe1aa
6
+ metadata.gz: e4dfbb234b9e84e911ec9c2d5b0477d144eed2c9904d06bed7a1f773646975a1f768277db68732750f2d2d91af509cc5d97b1dbff88f541ab28afb8ee7055c1e
7
+ data.tar.gz: eecd735270b91d2b8e204edbf547be8f77df5094123590a900c574cb54b2a3fe95eb9295940fab6e097abd396b45417f254269f4a84a9a82ed44b6bc296f0f0f
@@ -10,12 +10,9 @@ Metrics/BlockLength:
10
10
  - "Gemfile"
11
11
  - "spec/**/*"
12
12
 
13
- Metrics/LineLength:
13
+ Layout/LineLength:
14
14
  Max: 120
15
15
 
16
- Style/BracesAroundHashParameters:
17
- EnforcedStyle: context_dependent
18
-
19
16
  Style/StringLiterals:
20
17
  EnforcedStyle: double_quotes
21
18
 
@@ -47,3 +44,11 @@ Style/TrailingCommaInHashLiteral:
47
44
  Enabled: true
48
45
  EnforcedStyleForMultiline: consistent_comma
49
46
 
47
+ Style/HashEachMethods:
48
+ Enabled: true
49
+
50
+ Style/HashTransformKeys:
51
+ Enabled: true
52
+
53
+ Style/HashTransformValues:
54
+ Enabled: true
@@ -1,5 +1,4 @@
1
1
  ---
2
- sudo: false
3
2
  language: ruby
4
3
  cache: bundler
5
4
  rvm:
@@ -5,6 +5,16 @@ 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.6.0 - 2020-07-15
9
+
10
+ ### Added
11
+
12
+ - `Yabeda.with_tags` to redefine default tags for limited amount of time–for all metrics measured during a block execution. [@Envek]
13
+
14
+ ### Fixed
15
+
16
+ - Default tags were not sent to adapters for metrics declared before `default_tag` declaration. [@Envek]
17
+
8
18
  ## 0.5.0 - 2020-01-29
9
19
 
10
20
  ### Added
data/Gemfile CHANGED
@@ -11,6 +11,6 @@ group :development, :test do
11
11
  gem "pry"
12
12
  gem "pry-byebug", platform: :mri
13
13
 
14
- gem "rubocop"
14
+ gem "rubocop", "~> 0.80.0"
15
15
  gem "rubocop-rspec"
16
16
  end
data/README.md CHANGED
@@ -84,11 +84,24 @@ And then execute:
84
84
  Yabeda.configure do
85
85
  default_tag :rails_environment, 'production'
86
86
  end
87
+
88
+ # You can redefine them for limited amount of time
89
+ Yabeda.with_tags(rails_environment: 'staging') do
90
+ Yabeda.your_app.bells_rang_count.increment({bell_size: bell.size}, by: 1)
91
+ end
87
92
  ```
88
93
 
89
94
  6. See the docs for the adapter you're using
90
95
  7. Enjoy!
91
96
 
97
+ ## Available monitoring system adapters
98
+
99
+ - [Prometheus](https://github.com/yabeda-rb/yabeda-prometheus)
100
+ - [Datadog](https://github.com/yabeda-rb/yabeda-datadog)
101
+ - [NewRelic](https://github.com/yabeda-rb/yabeda-newrelic)
102
+ - [Statsd](https://github.com/asusikov/yabeda-statsd)
103
+ - _…and more! You can write your own adapter and open a pull request to add it into this list._
104
+
92
105
  ## Roadmap (aka TODO or Help wanted)
93
106
 
94
107
  - Ability to change metric settings for individual adapters
@@ -60,6 +60,7 @@ module Yabeda
60
60
 
61
61
  # Perform configuration: registration of metrics and collector blocks
62
62
  # @return [void]
63
+ # rubocop: disable Metrics/MethodLength, Metrics/AbcSize
63
64
  def configure!
64
65
  raise(AlreadyConfiguredError, @configured_by) if already_configured?
65
66
 
@@ -69,8 +70,17 @@ module Yabeda
69
70
  group nil
70
71
  end
71
72
 
73
+ # Register metrics in adapters after evaluating all configuration blocks
74
+ # to ensure that all global settings (like default tags) will be applied.
75
+ adapters.each_value do |adapter|
76
+ metrics.each_value do |metric|
77
+ adapter.register!(metric)
78
+ end
79
+ end
80
+
72
81
  @configured_by = caller_locations(1, 1)[0].to_s
73
82
  end
83
+ # rubocop: enable Metrics/MethodLength, Metrics/AbcSize
74
84
 
75
85
  # Forget all the configuration.
76
86
  # For testing purposes as it doesn't rollback changes in adapters.
@@ -62,13 +62,28 @@ module Yabeda
62
62
  ::Yabeda.default_tags[name] = value
63
63
  end
64
64
 
65
+ # Redefine default tags for a limited amount of time
66
+ # @param tags Hash{Symbol=>#to_s}
67
+ def with_tags(**tags)
68
+ Thread.current[:yabeda_temporary_tags] = tags
69
+ yield
70
+ ensure
71
+ Thread.current[:yabeda_temporary_tags] = {}
72
+ end
73
+
74
+ # Get tags set by +with_tags+
75
+ # @api private
76
+ # @return Hash
77
+ def temporary_tags
78
+ Thread.current[:yabeda_temporary_tags] || {}
79
+ end
80
+
65
81
  private
66
82
 
67
83
  def register_metric(metric)
68
84
  name = [metric.group, metric.name].compact.join("_")
69
85
  ::Yabeda.define_singleton_method(name) { metric }
70
86
  ::Yabeda.metrics[name] = metric
71
- ::Yabeda.adapters.each_value { |adapter| adapter.register!(metric) }
72
87
  register_group_for(metric) if metric.group
73
88
  metric
74
89
  end
@@ -4,7 +4,7 @@ module Yabeda
4
4
  # Class to merge tags
5
5
  class Tags
6
6
  def self.build(tags)
7
- ::Yabeda.default_tags.merge(tags)
7
+ ::Yabeda.default_tags.merge(Yabeda.temporary_tags, tags)
8
8
  end
9
9
  end
10
10
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Yabeda
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.0"
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.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Novikov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-29 00:00:00.000000000 Z
11
+ date: 2020-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -111,7 +111,7 @@ dependencies:
111
111
  description: 'Collect statistics about how your application is performing with ease.
112
112
  Export metrics to various monitoring systems.
113
113
 
114
- '
114
+ '
115
115
  email:
116
116
  - envek@envek.name
117
117
  executables: []
@@ -149,7 +149,7 @@ homepage: https://github.com/yabeda-rb/yabeda
149
149
  licenses:
150
150
  - MIT
151
151
  metadata: {}
152
- post_install_message:
152
+ post_install_message:
153
153
  rdoc_options: []
154
154
  require_paths:
155
155
  - lib
@@ -164,8 +164,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  - !ruby/object:Gem::Version
165
165
  version: '0'
166
166
  requirements: []
167
- rubygems_version: 3.0.3
168
- signing_key:
167
+ rubygems_version: 3.1.2
168
+ signing_key:
169
169
  specification_version: 4
170
170
  summary: Extensible framework for collecting metric for your Ruby application
171
171
  test_files: []