yabeda-prometheus 0.2.0 → 0.5.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: c5e54ecad52d7b0afa0763c586097de00a8dda93c125116fb879fad20d7ce40c
4
- data.tar.gz: 1f8dce2a20922f7a175191660ff5de7719893a6b741dffd8d06064867ec07cfe
3
+ metadata.gz: 59af7a9f1de7593f49c9d58f1f9517c15182a7000d86d1076fa06297371013e2
4
+ data.tar.gz: 470bb2054c3f3281754ba07c7fd3217c83213c139150c27dd52c0d5ee8577b02
5
5
  SHA512:
6
- metadata.gz: b800c70319409c9d9afd4f88599c8e881f146825ccd5ed8ebd232efc16c5df78760c9adbe1b291747c6990d13f7c7703893344d0003954f5c902f119d779b672
7
- data.tar.gz: c5c5f923c9a97d5633487998850dae2e1bac9a1e34ed3f0a0d679c5d414a14452fc33c910f853b09f4376e7dcf714fa58efa09cdb04cca1f062404e5f3f8dd65
6
+ metadata.gz: 1fef847b5af1e283109303d04b3b9df56b8439a120dcad11ab7934dc5102147cd5fca35ae2719e05dd5d06c6ff06b752bcd566a3e13dd6bf26e64b0dec83e37b
7
+ data.tar.gz: 25e463b8f562504d21e856c99192ec516aec2dacf6faa75b20266d78421252a09ab57e57135f529189add2a8c78fafa9a7803b91949c0a3488a00030f92a7bfb
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ 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.5.0 - 2020-01-29
9
+
10
+ ### Added
11
+
12
+ - Support for metric aggregation when prometheus-client's Direct File Store is used. @Envek
13
+
14
+ See https://github.com/prometheus/client_ruby#aggregation-settings-for-multi-process-stores for details.
15
+
8
16
  ## 0.2.0 - 2020-01-14
9
17
 
10
18
  ### Changed
data/README.md CHANGED
@@ -73,6 +73,19 @@ Prometheus::Client.config.data_store = Prometheus::Client::DataStores::DirectFil
73
73
 
74
74
  See more information at [prometheus-client README](https://github.com/prometheus/client_ruby#data-stores).
75
75
 
76
+ ### Aggregation settings
77
+
78
+ You can specify aggregation policy in gauges declaration:
79
+
80
+ ```ruby
81
+ group :some do
82
+ gauge :tasks do
83
+ comment "Number of test tasks"
84
+ aggregation :max
85
+ end
86
+ end
87
+ ```
88
+
76
89
  ## Development
77
90
 
78
91
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "prometheus/client"
4
+ require 'prometheus/client/data_stores/direct_file_store'
5
+ require 'prometheus/client/data_stores/single_threaded'
4
6
  require "yabeda/base_adapter"
5
7
 
6
8
  module Yabeda
@@ -23,7 +25,12 @@ module Yabeda
23
25
 
24
26
  def register_counter!(metric)
25
27
  validate_metric!(metric)
26
- registry.counter(build_name(metric), docstring: metric.comment, labels: Array(metric.tags))
28
+ registry.counter(
29
+ build_name(metric),
30
+ docstring: metric.comment,
31
+ labels: Array(metric.tags),
32
+ store_settings: store_settings(metric),
33
+ )
27
34
  end
28
35
 
29
36
  def perform_counter_increment!(metric, tags, value)
@@ -34,7 +41,12 @@ module Yabeda
34
41
 
35
42
  def register_gauge!(metric)
36
43
  validate_metric!(metric)
37
- registry.gauge(build_name(metric), docstring: metric.comment, labels: Array(metric.tags))
44
+ registry.gauge(
45
+ build_name(metric),
46
+ docstring: metric.comment,
47
+ labels: Array(metric.tags),
48
+ store_settings: store_settings(metric),
49
+ )
38
50
  end
39
51
 
40
52
  def perform_gauge_set!(metric, tags, value)
@@ -46,7 +58,13 @@ module Yabeda
46
58
  def register_histogram!(metric)
47
59
  validate_metric!(metric)
48
60
  buckets = metric.buckets || ::Prometheus::Client::Histogram::DEFAULT_BUCKETS
49
- registry.histogram(build_name(metric), docstring: metric.comment, buckets: buckets, labels: Array(metric.tags))
61
+ registry.histogram(
62
+ build_name(metric),
63
+ docstring: metric.comment,
64
+ buckets: buckets,
65
+ labels: Array(metric.tags),
66
+ store_settings: store_settings(metric),
67
+ )
50
68
  end
51
69
 
52
70
  def perform_histogram_measure!(metric, tags, value)
@@ -65,6 +83,19 @@ module Yabeda
65
83
  raise ArgumentError, 'Prometheus require metrics to have comments'
66
84
  end
67
85
 
86
+ private
87
+
88
+ # @param metric [Yabeda::Metric]
89
+ # @return [Hash]
90
+ def store_settings(metric)
91
+ case ::Prometheus::Client.config.data_store
92
+ when ::Prometheus::Client::DataStores::Synchronized, ::Prometheus::Client::DataStores::SingleThreaded
93
+ {} # Default synchronized store doesn't allow to pass any options
94
+ when ::Prometheus::Client::DataStores::DirectFileStore, ::Object # Anything else
95
+ { aggregation: metric.aggregation }.compact
96
+ end
97
+ end
98
+
68
99
  Yabeda.register_adapter(:prometheus, new)
69
100
  end
70
101
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module Prometheus
5
- VERSION = "0.2.0"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.required_ruby_version = ">= 2.3"
29
29
 
30
30
  spec.add_dependency "prometheus-client", "~> 1.0"
31
- spec.add_dependency "yabeda", "~> 0.2"
31
+ spec.add_dependency "yabeda", "~> 0.5"
32
32
 
33
33
  spec.add_development_dependency "bundler", "~> 1.17"
34
34
  spec.add_development_dependency "rake", "~> 12.0"
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.2.0
4
+ version: 0.5.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-14 00:00:00.000000000 Z
11
+ date: 2020-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prometheus-client
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.2'
33
+ version: '0.5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.2'
40
+ version: '0.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement