yabeda-prometheus 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +37 -0
- data/README.md +12 -5
- data/lib/yabeda/prometheus/exporter.rb +20 -11
- data/lib/yabeda/prometheus/version.rb +1 -1
- data/yabeda-prometheus.gemspec +5 -1
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99160ecfcc0c1d30b0ce7c02444eb245958cbf05a09ebbed89f016ab5b1e2118
|
4
|
+
data.tar.gz: 85918fdb24afad2f8d3bd3d64fea86be86e97b5f740cb8affce9f5cf0fdf336c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c73f0756cba70bd4b6da0532108aec67013532f0fbb96907677956db0aeede567fb3f2d32bec1b922ea3eebb0a8c48643de2ccdf798c8a3a77f389b37ad5b46
|
7
|
+
data.tar.gz: 8704ba138071f06b6dc8eecdd6fbbb9349a4d1585a647f5d0ec0050d37dae69225f06e0fbbd7b802591b16d54687d9c079b111658a0a6fbec525f983783fd693
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
6
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
|
9
|
+
## 0.1.3 - 2018-10-31
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- Ability to mount exporter to Rails application routes as standalone Rack app. @Envek
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
Rails.application.routes.draw do
|
17
|
+
mount Yabeda::Prometheus::Exporter => "/metrics"
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
## 0.1.2 - 2018-10-17
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- Renamed evil-metrics-prometheus gem to yabeda-prometheus. @Envek
|
26
|
+
|
27
|
+
## 0.1.1 - 2018-10-05
|
28
|
+
|
29
|
+
### Changed
|
30
|
+
|
31
|
+
- Eliminate data duplication in counters and gauges. @Envek
|
32
|
+
|
33
|
+
Use values stored in core gem metric objects and just let Prometheus to read them.
|
34
|
+
|
35
|
+
## 0.1.0 - 2018-10-03
|
36
|
+
|
37
|
+
- Initial release of evil-metrics-prometheus gem. @Envek
|
data/README.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# Yabeda::[Prometheus]
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/yabeda-prometheus.svg)](https://rubygems.org/gems/yabeda-prometheus)
|
4
|
+
|
5
|
+
Adapter for easy exporting your collected metrics from your application to the [Prometheus]!
|
6
|
+
|
7
|
+
<a href="https://evilmartians.com/?utm_source=yabeda-prometheus&utm_campaign=project_page">
|
8
|
+
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54">
|
9
|
+
</a>
|
10
|
+
|
4
11
|
|
5
12
|
## One more? Why not X?
|
6
13
|
|
@@ -12,9 +19,7 @@ Adapter for easy exporting your collected evil metrics from your application to
|
|
12
19
|
Add this line to your application's Gemfile:
|
13
20
|
|
14
21
|
```ruby
|
15
|
-
gem 'yabeda'
|
16
|
-
# Then add monitoring system adapter, e.g.:
|
17
|
-
# gem 'yabeda-prometheus'
|
22
|
+
gem 'yabeda-prometheus'
|
18
23
|
```
|
19
24
|
|
20
25
|
And then execute:
|
@@ -31,7 +36,9 @@ And then execute:
|
|
31
36
|
use Yabeda::Prometheus::Exporter
|
32
37
|
```
|
33
38
|
|
34
|
-
Metrics will be available on `/metrics` path.
|
39
|
+
Metrics will be available on `/metrics` path (configured by `:path` option).
|
40
|
+
|
41
|
+
Also you can mount it in Rails application routes as standalone Rack application.
|
35
42
|
|
36
43
|
2. Run web-server from long-running processes (delayed jobs, …):
|
37
44
|
|
@@ -4,11 +4,22 @@ require "prometheus/middleware/exporter"
|
|
4
4
|
|
5
5
|
module Yabeda
|
6
6
|
module Prometheus
|
7
|
+
# Rack application or middleware that provides metrics exposition endpoint
|
7
8
|
class Exporter < ::Prometheus::Middleware::Exporter
|
9
|
+
NOT_FOUND_HANDLER = lambda do |_env|
|
10
|
+
[404, { "Content-Type" => "text/plain" }, ["Not Found\n"]]
|
11
|
+
end.freeze
|
12
|
+
|
8
13
|
class << self
|
14
|
+
# Allows to use middleware as standalone rack application
|
15
|
+
def call(env)
|
16
|
+
@app ||= new(NOT_FOUND_HANDLER, path: "/")
|
17
|
+
@app.call(env)
|
18
|
+
end
|
19
|
+
|
9
20
|
def start_metrics_server!
|
10
21
|
Thread.new do
|
11
|
-
default_port = ENV.fetch("PORT",
|
22
|
+
default_port = ENV.fetch("PORT", 9394)
|
12
23
|
Rack::Handler::WEBrick.run(
|
13
24
|
rack_app,
|
14
25
|
Host: ENV["PROMETHEUS_EXPORTER_BIND"] || "0.0.0.0",
|
@@ -18,24 +29,22 @@ module Yabeda
|
|
18
29
|
end
|
19
30
|
end
|
20
31
|
|
21
|
-
|
22
|
-
|
23
|
-
def rack_app(exporter = self)
|
32
|
+
def rack_app(exporter = self, path: "/metrics")
|
24
33
|
Rack::Builder.new do
|
25
34
|
use Rack::CommonLogger
|
26
35
|
use Rack::ShowExceptions
|
27
|
-
use exporter,
|
28
|
-
run
|
29
|
-
[404, { "Content-Type" => "text/plain" }, ["Not Found\n"]]
|
30
|
-
end
|
36
|
+
use exporter, path: path
|
37
|
+
run NOT_FOUND_HANDLER
|
31
38
|
end
|
32
39
|
end
|
33
40
|
end
|
34
41
|
|
42
|
+
def initialize(app, options = {})
|
43
|
+
super(app, options.merge(registry: Yabeda::Prometheus.registry))
|
44
|
+
end
|
45
|
+
|
35
46
|
def call(env)
|
36
|
-
if env["
|
37
|
-
Yabeda.collectors.each(&:call)
|
38
|
-
end
|
47
|
+
Yabeda.collectors.each(&:call) if env["PATH_INFO"] == path
|
39
48
|
super
|
40
49
|
end
|
41
50
|
end
|
data/yabeda-prometheus.gemspec
CHANGED
@@ -14,6 +14,10 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "https://github.com/yabeda-rb/yabeda-prometheus"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/yabeda-rb/yabeda-prometheus"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/yabeda-rb/yabeda-prometheus/blob/master/CHANGELOG.md"
|
20
|
+
|
17
21
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
22
|
f.match(%r{^(test|spec|features)/})
|
19
23
|
end
|
@@ -24,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
24
28
|
spec.add_dependency "yabeda"
|
25
29
|
spec.add_dependency "prometheus-client"
|
26
30
|
|
27
|
-
spec.add_development_dependency "bundler", "~> 1.
|
31
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
28
32
|
spec.add_development_dependency "rake", "~> 12.0"
|
29
33
|
spec.add_development_dependency "rspec", "~> 3.0"
|
30
34
|
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
|
+
version: 0.1.3
|
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-10-
|
11
|
+
date: 2018-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yabeda
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.17'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1.
|
54
|
+
version: '1.17'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- ".rspec"
|
92
92
|
- ".rubocop.yml"
|
93
93
|
- ".travis.yml"
|
94
|
+
- CHANGELOG.md
|
94
95
|
- Gemfile
|
95
96
|
- LICENSE.txt
|
96
97
|
- README.md
|
@@ -108,7 +109,10 @@ files:
|
|
108
109
|
homepage: https://github.com/yabeda-rb/yabeda-prometheus
|
109
110
|
licenses:
|
110
111
|
- MIT
|
111
|
-
metadata:
|
112
|
+
metadata:
|
113
|
+
homepage_uri: https://github.com/yabeda-rb/yabeda-prometheus
|
114
|
+
source_code_uri: https://github.com/yabeda-rb/yabeda-prometheus
|
115
|
+
changelog_uri: https://github.com/yabeda-rb/yabeda-prometheus/blob/master/CHANGELOG.md
|
112
116
|
post_install_message:
|
113
117
|
rdoc_options: []
|
114
118
|
require_paths:
|