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 +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +19 -19
- data/lib/prometheus_reporter/text_formatter.rb +6 -1
- data/lib/prometheus_reporter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fae87b53213b822058903b0c524c2213ccf43702
|
4
|
+
data.tar.gz: 5abac85356c30d2948797ee6086666945d3cb925
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 253dcc039a2952010428dd395faef3b6ce182b9ad2a384b830fcc489fbadd96ef08a09efd62e70f3129f9ebef3746a0114a4f67d205eec3135c331725651ee6a
|
7
|
+
data.tar.gz: c6f7b19c5d3dbb1413df75135c8d778c70608b25c2aadc46a103a4ced08d0cfb09a7c2a1ad7ddb7d60f38b78b20d84f076ea578a6b3d6f5070fcb8d0574ec6d8
|
data/CHANGELOG.md
CHANGED
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.
|
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
|
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.
|
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-
|
11
|
+
date: 2018-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|