yabeda-prometheus 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1922a6edd3de4513c03bb3405280060973cfe6c0004b56be0bf0c923934eb82f
4
- data.tar.gz: acc3a06038a5cf9f972406b0edd466ae04f49643d2ad784d0c9e2565919a7308
3
+ metadata.gz: cf7f044078d39963972005e5dab30c8fa8d908ca9b1d667ce60fc36295e7fb91
4
+ data.tar.gz: bd89b7fa736a501e417345951c642d601af60dd537a8c03a80a11678990e61d1
5
5
  SHA512:
6
- metadata.gz: ed6e18d43df3f06ad848c6b6965e7093a71ba36d4c34e3e3bfb93f43eda220bf738436604f0db3ae63e026e53bd6eccfe6ec9f60d667a4cb0687f7ac2a9ce5bb
7
- data.tar.gz: 2b77cc35bc3f5e72033aa624371630d6221ba54dc5d3ea5c222db62a12bddca589c5c5bf7bc5925e76de0d5d38083fe5ae7c754bcb913492a2af34b8c9970753
6
+ metadata.gz: 2caa793706298308666cd8355eb8a04d7b56fd810fbd6ca57705246845e1cc229ce664fd70c284147fe998cf1e464580c7743af8e7aec28d569ec1f9a42c8fe8
7
+ data.tar.gz: 8fcf2724292390d4115c2872c4bc1de2fc2f6d5435a9fb6a26eec06444b6b3a4428cee18fbf8cb7b4af14a61e175fc0aea9e46f9639acfc268259a1396496526
@@ -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.1.5 - 2019-10-15
9
+
10
+ ### Fixed
11
+
12
+ - Issue [#7](https://github.com/yabeda-rb/yabeda-prometheus/issues/7) with counters and gauges when using prometheus-client-mmap gem. Fixed in [#8](https://github.com/yabeda-rb/yabeda-prometheus/pull/8) by [@alexander37137]
13
+
8
14
 
9
15
  ## 0.1.4 - 2018-11-06
10
16
 
@@ -57,3 +63,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
57
63
  ## 0.1.0 - 2018-10-03
58
64
 
59
65
  - Initial release of evil-metrics-prometheus gem. @Envek
66
+
67
+ [@alexander37137]: https://github.com/alexander37137 "Alexander Andreev"
@@ -3,9 +3,6 @@
3
3
  require "prometheus/client"
4
4
  require "yabeda/base_adapter"
5
5
 
6
- require_relative "./counter_wrapper"
7
- require_relative "./gauge_wrapper"
8
-
9
6
  module Yabeda
10
7
  class Prometheus::Adapter < BaseAdapter
11
8
  def registry
@@ -14,20 +11,20 @@ module Yabeda
14
11
 
15
12
  def register_counter!(metric)
16
13
  validate_metric!(metric)
17
- registry.register(Prometheus::CounterWrapper.new(metric))
14
+ registry.counter(build_name(metric), metric.comment)
18
15
  end
19
16
 
20
- def perform_counter_increment!(*)
21
- # Do nothing. Prometheus will read current value from evil metric
17
+ def perform_counter_increment!(metric, tags, value)
18
+ registry.get(build_name(metric)).increment(tags, value)
22
19
  end
23
20
 
24
21
  def register_gauge!(metric)
25
22
  validate_metric!(metric)
26
- registry.register(Prometheus::GaugeWrapper.new(metric))
23
+ registry.gauge(build_name(metric), metric.comment)
27
24
  end
28
25
 
29
- def perform_gauge_set!(*)
30
- # Do nothing. Prometheus will read current value from evil metric
26
+ def perform_gauge_set!(metric, tags, value)
27
+ registry.get(build_name(metric)).set(tags, value)
31
28
  end
32
29
 
33
30
  def register_histogram!(metric)
@@ -41,13 +38,13 @@ module Yabeda
41
38
  end
42
39
 
43
40
  def build_name(metric)
44
- [metric.group, metric.name, metric.unit].compact.join("_").to_sym
41
+ [metric.group, metric.name, metric.unit].compact.join('_').to_sym
45
42
  end
46
43
 
47
44
  def validate_metric!(metric)
48
45
  return if metric.comment
49
46
 
50
- raise ArgumentError, "Prometheus require metrics to have comments"
47
+ raise ArgumentError, 'Prometheus require metrics to have comments'
51
48
  end
52
49
 
53
50
  Yabeda.register_adapter(:prometheus, new)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module Prometheus
5
- VERSION = "0.1.4"
5
+ VERSION = "0.1.5"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yabeda-prometheus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
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-11-06 00:00:00.000000000 Z
11
+ date: 2019-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yabeda
@@ -86,10 +86,7 @@ files:
86
86
  - bin/setup
87
87
  - lib/yabeda/prometheus.rb
88
88
  - lib/yabeda/prometheus/adapter.rb
89
- - lib/yabeda/prometheus/counter_wrapper.rb
90
89
  - lib/yabeda/prometheus/exporter.rb
91
- - lib/yabeda/prometheus/gauge_wrapper.rb
92
- - lib/yabeda/prometheus/metric_wrapper.rb
93
90
  - lib/yabeda/prometheus/version.rb
94
91
  - yabeda-prometheus.gemspec
95
92
  homepage: https://github.com/yabeda-rb/yabeda-prometheus
@@ -117,8 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
114
  - !ruby/object:Gem::Version
118
115
  version: '0'
119
116
  requirements: []
120
- rubyforge_project:
121
- rubygems_version: 2.7.6
117
+ rubygems_version: 3.0.3
122
118
  signing_key:
123
119
  specification_version: 4
124
120
  summary: Extensible Prometheus exporter for your application
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "./metric_wrapper"
4
-
5
- module Yabeda
6
- class Prometheus::CounterWrapper < Prometheus::MetricWrapper
7
- def type
8
- :counter
9
- end
10
-
11
- def increment(labels = {}, by = 1)
12
- metric.increment(labels, by: by)
13
- end
14
- end
15
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "./metric_wrapper"
4
-
5
- module Yabeda
6
- class Prometheus::GaugeWrapper < Prometheus::MetricWrapper
7
- def type
8
- :gauge
9
- end
10
-
11
- def set(labels, value)
12
- unless value.is_a?(Numeric)
13
- raise ArgumentError, 'value must be a number'
14
- end
15
-
16
- metric.set(labels, value)
17
- end
18
- end
19
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "prometheus/client/metric"
4
-
5
- module Yabeda
6
- class Prometheus::MetricWrapper < ::Prometheus::Client::Metric
7
- attr_reader :metric
8
-
9
- def initialize(metric, base_labels = {})
10
- @metric = metric
11
-
12
- @validator = ::Prometheus::Client::LabelSetValidator.new
13
- @base_labels = base_labels
14
-
15
- validate_name(self.name)
16
- validate_docstring(self.docstring)
17
- @validator.valid?(base_labels)
18
- end
19
-
20
- def name
21
- @name ||=
22
- [metric.group, metric.name, metric.unit].compact.join("_").to_sym
23
- end
24
-
25
- def docstring
26
- metric.comment
27
- end
28
-
29
- def get(labels = {})
30
- @validator.valid?(labels)
31
-
32
- metric.get(labels)
33
- end
34
-
35
- def values
36
- metric.values
37
- end
38
- end
39
- end