prometheus_reporter 1.1.0 → 1.1.1

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
  SHA1:
3
- metadata.gz: c11682f278ffa6194feba297168ed641d4824b1c
4
- data.tar.gz: cdfeba4d64550cb025823205cd97e43b6cea3047
3
+ metadata.gz: fae87b53213b822058903b0c524c2213ccf43702
4
+ data.tar.gz: 5abac85356c30d2948797ee6086666945d3cb925
5
5
  SHA512:
6
- metadata.gz: 8f43647a52cb5db960921c3fe8d821760a739d9513a0d53ee8fcaa856555d6555eca907ea407f9fbb5ee253734f665f70346d9c8df59ea1e5a5149b8e0d04d01
7
- data.tar.gz: 2fc302c361a09b9af7fc1ccc82c1aad3f7c75faadd21b0eda5fe1c393fa4934b2a7fe5fd75e5b9cd39f3a7d22d1b74e4653a145b1ca09254f04d78be056f34b0
6
+ metadata.gz: 253dcc039a2952010428dd395faef3b6ce182b9ad2a384b830fcc489fbadd96ef08a09efd62e70f3129f9ebef3746a0114a4f67d205eec3135c331725651ee6a
7
+ data.tar.gz: c6f7b19c5d3dbb1413df75135c8d778c70608b25c2aadc46a103a4ced08d0cfb09a7c2a1ad7ddb7d60f38b78b20d84f076ea578a6b3d6f5070fcb8d0574ec6d8
@@ -1,3 +1,6 @@
1
+ ## 1.1.1 (2018-01-31)
2
+ Report is always the same despite the order of methods called
3
+
1
4
  ## 1.1.0 (2018-01-15)
2
5
  Added TextFormatter.draw method with DSL
3
6
 
data/README.md CHANGED
@@ -23,7 +23,7 @@ $ gem install prometheus_reporter
23
23
  ```
24
24
  or using `Gemfile`:
25
25
  ```ruby
26
- gem 'prometheus_reporter', '~> 1.0'
26
+ gem 'prometheus_reporter', '~> 1.1.1'
27
27
  ```
28
28
  ## Configuration
29
29
 
@@ -52,6 +52,24 @@ f.to_s # => "facebook_clone_emails_count 987\n"
52
52
 
53
53
  ## Usage
54
54
 
55
+ ### DSL
56
+
57
+ You can also use DSL to define reports:
58
+
59
+ ```ruby
60
+ report =
61
+ PrometheusReporter::TextFormatter.draw(prefix: 'my_application') do
62
+ type :emails_today, :counter
63
+ entry :emails_today, value: 1337
64
+
65
+ type :registrations_today, :counter
66
+ entry :registrations_today, value: 105
67
+
68
+ type :payments_total, :summary
69
+ entry :payments_total, 29913
70
+ end
71
+ ```
72
+
55
73
  ### Creating text report for Prometheus:
56
74
 
57
75
  ```ruby
@@ -80,24 +98,6 @@ facebook_clone_emails_today{type="notify_for_inactivity"} 10 1515681885
80
98
  facebook_clone_emails_today{type="registration_confirmation"} 18 1515681886
81
99
  ```
82
100
 
83
- ### DSL
84
-
85
- You can also use DSL to define reports:
86
-
87
- ```ruby
88
- report =
89
- PrometheusReporter::TextFormatter.draw(prefix: 'my_application') do
90
- type :emails_today, :counter
91
- entry :emails_today, value: 1337
92
-
93
- type :registrations_today, :counter
94
- entry :registrations_today, value: 105
95
-
96
- type :payments_total, :summary
97
- entry :payments_total, 29913
98
- end
99
- ```
100
-
101
101
  ## Usefull links
102
102
  - Official Prometheus [ruby client](https://github.com/prometheus/client_ruby)
103
103
  - [Prometheus](https://github.com/prometheus) itself
@@ -50,7 +50,7 @@ module PrometheusReporter
50
50
  def to_s
51
51
  metrics_data = []
52
52
 
53
- @data.each do |prometheus_key_name, prometheus_key_values|
53
+ sort_hash(@data).each do |prometheus_key_name, prometheus_key_values|
54
54
  prometheus_key_values = prometheus_key_values.compact
55
55
  validate_data!(prometheus_key_name, prometheus_key_values)
56
56
  metrics_data << metric_entry(prometheus_key_name, prometheus_key_values)
@@ -89,6 +89,7 @@ module PrometheusReporter
89
89
  prometheus_key_values.each do |label_or_token, value|
90
90
  metric_lines << text_entry(prometheus_key_name, label_or_token, value)
91
91
  end
92
+ metric_lines.sort!
92
93
  (metric_lines << nil).join(SEPARATOR)
93
94
  end
94
95
 
@@ -120,5 +121,9 @@ module PrometheusReporter
120
121
 
121
122
  "{#{labels_str}}"
122
123
  end
124
+
125
+ def sort_hash(hash)
126
+ Hash[hash.sort]
127
+ end
123
128
  end
124
129
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PrometheusReporter
4
- VERSION = '1.1.0'
4
+ VERSION = '1.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prometheus_reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleksii Kuznietsov (nattfodd)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-15 00:00:00.000000000 Z
11
+ date: 2018-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry