greek_fire 0.2.0 → 0.2.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/README.md +82 -3
- data/lib/greek_fire/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9c5085e674c0a4e11ab3237d271e2fe6bbcf21a
|
4
|
+
data.tar.gz: 9fd4d7109fe2db2e9529b41f385bbca83644237e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ef24b3b4e0b281e4f78ccd1b592cc654af4439805eaf40cfb62fc7811f0fb552f48057abbc09a11964587c67b7584f02bfa07cdfc847862ebb4e8e42918dbb9
|
7
|
+
data.tar.gz: 9c2b7cc1019aa3ee0d393e850960f3abe9d0aea4c5e228a2c2daf87b11ba3f6c573f9e86e02bdef7d05a5bdd90af656c8f931dfb115835d409882d85a569eb28
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# GreekFire
|
2
|
-
|
2
|
+
Prometheus metrics for rails.
|
3
3
|
|
4
4
|
## Usage
|
5
5
|
How to use my plugin.
|
6
6
|
|
7
|
-
|
7
|
+
### Installation
|
8
8
|
Add this line to your application's Gemfile:
|
9
9
|
|
10
10
|
```ruby
|
@@ -21,8 +21,87 @@ Or install it yourself as:
|
|
21
21
|
$ gem install greek_fire
|
22
22
|
```
|
23
23
|
|
24
|
+
### Mount the engine
|
25
|
+
|
26
|
+
config/routes.rb:
|
27
|
+
```ruby
|
28
|
+
mount GreekFire::Engine => '/metrics'
|
29
|
+
```
|
30
|
+
|
31
|
+
### Add yer metrics
|
32
|
+
|
33
|
+
config/initializers/greek_fire.rb:
|
34
|
+
```ruby
|
35
|
+
|
36
|
+
GreekFire::Gauge.register "a_generic_metric" do
|
37
|
+
GenericModel.where('created_at > ?', Time.zone.now.advance(minutes: -1)).count
|
38
|
+
end
|
39
|
+
|
40
|
+
GreekFire::Gauge.register "another_generic_metric"
|
41
|
+
description: "describes the metric",
|
42
|
+
labels: {:a_label: [1, 2], b_label: "foo"} do | labels |
|
43
|
+
AnotherModel.where('created_at > ?', Time.zone.now.advance(minutes: -1)).count
|
44
|
+
end
|
45
|
+
|
46
|
+
GreekFire::Gauge.register "sidekiq_job_latency",
|
47
|
+
description: "How long are jobs enqueued",
|
48
|
+
labels: { :queue => Proc.new { Sidekiq::Queue.all.map(&:name) }} do | labels |
|
49
|
+
Sidekiq::Queue.new(labels[:queue]).latency
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
GreekFire::Gauge.register "sidekiq_job_count",
|
54
|
+
description: "How many jobs are enqueued",
|
55
|
+
labels: { :queue => Proc.new { Sidekiq::Queue.all.map(&:name) }} do | labels |
|
56
|
+
Sidekiq::Queue.new(labels[:queue]).size
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
60
|
+
## Metrics API
|
61
|
+
The api for creating metrics.
|
62
|
+
|
63
|
+
Currently only gauge type metrics are supported, but other metrics are a PR away!
|
64
|
+
|
65
|
+
### Gauges
|
66
|
+
```
|
67
|
+
module GreekFire
|
68
|
+
class Gauge
|
69
|
+
def self.register(name, description:nil, labels:nil, &block)
|
70
|
+
...
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
```
|
75
|
+
|
76
|
+
To register a Gauge (point in time value) call the above method.
|
77
|
+
|
78
|
+
### Labels
|
79
|
+
Labels are a hash of label_name to label_value(s).
|
80
|
+
A label_value may be a collection of values for the labels, or a Proc that returns a collection of label values.
|
81
|
+
|
82
|
+
The cross product of all possible label values are used to call the given block.
|
83
|
+
|
84
|
+
For example, a gauge with the following labels:
|
85
|
+
```ruby
|
86
|
+
{a_label: [1, 2], b_label: Proc.new { ["some", "list"] }, c_label: "c" }
|
87
|
+
```
|
88
|
+
|
89
|
+
would have it's block called one for each of the following hashes:
|
90
|
+
```ruby
|
91
|
+
{a_label: 1, b_label: "some", c_label: "c" }
|
92
|
+
{a_label: 1, b_label: "list", c_label: "c" }
|
93
|
+
{a_label: 2, b_label: "some", c_label: "c" }
|
94
|
+
{a_label: 2, b_label: "list", c_label: "c" }
|
95
|
+
```
|
96
|
+
|
97
|
+
If the label_value is a Proc, the Proc will be called each time metrics are requested. This should allow you to export metrics across label dimentions that change as your app runs. In the installation example you can see that the `sidekiq_job_count` and `sidekiq_job_latency` gauges will have a metrics produced for each queue the app is using.
|
98
|
+
|
24
99
|
## Contributing
|
25
|
-
|
100
|
+
|
101
|
+
1. Fork
|
102
|
+
2. Write tests.
|
103
|
+
3. Implement new feature.
|
104
|
+
4. Create a PR.
|
26
105
|
|
27
106
|
## License
|
28
107
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/lib/greek_fire/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: greek_fire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cconstantine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-rails
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 4.2.0
|
69
|
-
description:
|
69
|
+
description: An easy way to export metrics for Prometheus.
|
70
70
|
email:
|
71
71
|
- chris@omadahealth.com
|
72
72
|
executables: []
|
@@ -90,7 +90,7 @@ files:
|
|
90
90
|
- lib/greek_fire/engine.rb
|
91
91
|
- lib/greek_fire/version.rb
|
92
92
|
- lib/tasks/greek_fire_tasks.rake
|
93
|
-
homepage: https://
|
93
|
+
homepage: https://github.com/omadahealth/greek_fire
|
94
94
|
licenses:
|
95
95
|
- MIT
|
96
96
|
metadata: {}
|
@@ -113,5 +113,5 @@ rubyforge_project:
|
|
113
113
|
rubygems_version: 2.5.1
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
|
-
summary:
|
116
|
+
summary: Prometheus metrics for rails.
|
117
117
|
test_files: []
|