yabeda 0.2.0 → 0.3.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 +8 -0
- data/README.md +9 -2
- data/lib/yabeda.rb +6 -0
- data/lib/yabeda/counter.rb +4 -3
- data/lib/yabeda/dsl/class_methods.rb +8 -0
- data/lib/yabeda/gauge.rb +3 -2
- data/lib/yabeda/histogram.rb +3 -2
- data/lib/yabeda/metric.rb +4 -0
- data/lib/yabeda/tags.rb +10 -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: 84d57c72434b9d26ac68f5244de32338f90203c73f8c488541ea3e284ca763bf
|
4
|
+
data.tar.gz: c06c5b0475a260a15962c98d89346fa894eebad8200e728234814686cedbee48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce0c24fc3f77ae77295b9b0746cc4885743a60bb9d02ce092f71beaf4493cf9bf135703ebfbb39d44c990aa2409c4e423fe99aeeebb6ac1f0cec2f0b5279496e
|
7
|
+
data.tar.gz: 3f709b4c288ccf9fed8ddf9f890de3182c427cfe3837e3bb47cc70eec350a754ee19736fd788eaa6b7ed3a9f785160301d597eff5347fa4506667ae16c4027d2
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,12 @@ 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.3.0 - 2020-01-15
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- Ability to specify default tag which value will be automatically added to all metrics. [#7](https://github.com/yabeda-rb/yabeda/pull/7) by [@asusikov].
|
13
|
+
|
8
14
|
## 0.2.0 - 2020-01-14
|
9
15
|
|
10
16
|
### Added
|
@@ -34,3 +40,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
34
40
|
## 0.1.0 - 2018-10-03
|
35
41
|
|
36
42
|
- Initial release of evil-metrics gem. @Envek
|
43
|
+
|
44
|
+
[@asusikov]: https://github.com/asusikov "Alexander Susikov"
|
data/README.md
CHANGED
@@ -71,8 +71,15 @@ And then execute:
|
|
71
71
|
end
|
72
72
|
```
|
73
73
|
|
74
|
-
4.
|
75
|
-
|
74
|
+
4. _Optionally_ setup default tags that will be added to all metrics
|
75
|
+
```ruby
|
76
|
+
Yabeda.configure do
|
77
|
+
default_tag :rails_environment, 'production'
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
81
|
+
5. See the docs for the adapter you're using
|
82
|
+
6. Enjoy!
|
76
83
|
|
77
84
|
## Roadmap (aka TODO or Help wanted)
|
78
85
|
|
data/lib/yabeda.rb
CHANGED
@@ -4,6 +4,7 @@ require "concurrent"
|
|
4
4
|
|
5
5
|
require "yabeda/version"
|
6
6
|
require "yabeda/dsl"
|
7
|
+
require "yabeda/tags"
|
7
8
|
|
8
9
|
# Extendable framework for collecting and exporting metrics from Ruby apps
|
9
10
|
module Yabeda
|
@@ -30,6 +31,11 @@ module Yabeda
|
|
30
31
|
@collectors ||= Concurrent::Array.new
|
31
32
|
end
|
32
33
|
|
34
|
+
# @return [Hash<Symbol, Symbol>] All added default tags
|
35
|
+
def default_tags
|
36
|
+
@default_tags ||= Concurrent::Hash.new
|
37
|
+
end
|
38
|
+
|
33
39
|
# @param [Symbol] name
|
34
40
|
# @param [BaseAdapter] instance
|
35
41
|
def register_adapter(name, instance)
|
data/lib/yabeda/counter.rb
CHANGED
@@ -4,11 +4,12 @@ module Yabeda
|
|
4
4
|
# Growing-only counter
|
5
5
|
class Counter < Metric
|
6
6
|
def increment(tags, by: 1)
|
7
|
-
|
7
|
+
all_tags = ::Yabeda::Tags.build(tags)
|
8
|
+
values[all_tags] += by
|
8
9
|
::Yabeda.adapters.each do |_, adapter|
|
9
|
-
adapter.perform_counter_increment!(self,
|
10
|
+
adapter.perform_counter_increment!(self, all_tags, by)
|
10
11
|
end
|
11
|
-
values[
|
12
|
+
values[all_tags]
|
12
13
|
end
|
13
14
|
|
14
15
|
def values
|
@@ -53,6 +53,14 @@ module Yabeda
|
|
53
53
|
register_metric(metric)
|
54
54
|
end
|
55
55
|
|
56
|
+
# Add default tag for all metric
|
57
|
+
#
|
58
|
+
# @param name [Symbol] Name of default tag
|
59
|
+
# @param value [String] Value of default tag
|
60
|
+
def default_tag(name, value)
|
61
|
+
::Yabeda.default_tags[name] = value
|
62
|
+
end
|
63
|
+
|
56
64
|
private
|
57
65
|
|
58
66
|
def register_metric(metric)
|
data/lib/yabeda/gauge.rb
CHANGED
@@ -4,9 +4,10 @@ module Yabeda
|
|
4
4
|
# Arbitrary value, can be changed in both sides
|
5
5
|
class Gauge < Metric
|
6
6
|
def set(tags, value)
|
7
|
-
|
7
|
+
all_tags = ::Yabeda::Tags.build(tags)
|
8
|
+
values[all_tags] = value
|
8
9
|
::Yabeda.adapters.each do |_, adapter|
|
9
|
-
adapter.perform_gauge_set!(self,
|
10
|
+
adapter.perform_gauge_set!(self, all_tags, value)
|
10
11
|
end
|
11
12
|
value
|
12
13
|
end
|
data/lib/yabeda/histogram.rb
CHANGED
@@ -7,9 +7,10 @@ module Yabeda
|
|
7
7
|
option :buckets
|
8
8
|
|
9
9
|
def measure(tags, value)
|
10
|
-
|
10
|
+
all_tags = ::Yabeda::Tags.build(tags)
|
11
|
+
values[all_tags] = value
|
11
12
|
::Yabeda.adapters.each do |_, adapter|
|
12
|
-
adapter.perform_histogram_measure!(self,
|
13
|
+
adapter.perform_histogram_measure!(self, all_tags, value)
|
13
14
|
end
|
14
15
|
value
|
15
16
|
end
|
data/lib/yabeda/metric.rb
CHANGED
data/lib/yabeda/tags.rb
ADDED
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.3.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-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- lib/yabeda/group.rb
|
142
142
|
- lib/yabeda/histogram.rb
|
143
143
|
- lib/yabeda/metric.rb
|
144
|
+
- lib/yabeda/tags.rb
|
144
145
|
- lib/yabeda/version.rb
|
145
146
|
- yabeda.gemspec
|
146
147
|
homepage: https://github.com/yabeda-rb/yabeda
|