yabeda-puma-plugin 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +17 -9
- data/CHANGELOG.md +9 -0
- data/Gemfile +5 -1
- data/README.md +12 -1
- data/docker-compose.yml +1 -1
- data/lib/puma/plugin/yabeda_prometheus.rb +59 -10
- data/lib/yabeda/puma/plugin/version.rb +1 -1
- data/yabeda-puma-plugin-logo.png +0 -0
- data/yabeda-puma-plugin.gemspec +2 -1
- metadata +22 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 162d9000d77164bd50dfb7745f5cccd24dd33fbc16924c1643b8403e0f4dcda8
|
4
|
+
data.tar.gz: 9933179275d105ac9f8e6b41c7e046f70b67df88a244dbbef62c6a37748720eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e49fe7f43fe1f8a68b2b221390ab77c4961b4f10776279d73e761580b193948a39c11d00913004f6cb9511398d603018e6ee07014faefb06c30328ddadeb992c
|
7
|
+
data.tar.gz: bdc45f4701f90333891c90f7d6657dafac35e171c636c68630a36571b9fc0e039654285b566a7b5b1bf4086ee88737ab40ebae8a1d05375566a32a296b2de8b9
|
data/.github/workflows/test.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
name:
|
1
|
+
name: Tests
|
2
2
|
|
3
3
|
on:
|
4
4
|
pull_request:
|
@@ -10,24 +10,32 @@ on:
|
|
10
10
|
|
11
11
|
jobs:
|
12
12
|
test:
|
13
|
-
name:
|
14
|
-
|
13
|
+
name: 'Puma ${{ matrix.puma }} on Ruby ${{ matrix.ruby }}'
|
14
|
+
# Skip running tests for local pull requests (use push event instead), run only for foreign ones
|
15
|
+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login != github.event.pull_request.base.repo.owner.login
|
15
16
|
runs-on: ubuntu-latest
|
16
17
|
strategy:
|
17
18
|
fail-fast: false
|
18
19
|
matrix:
|
19
20
|
include:
|
20
|
-
- ruby: 3.
|
21
|
-
|
22
|
-
- ruby:
|
23
|
-
|
21
|
+
- ruby: "3.1"
|
22
|
+
puma: "6"
|
23
|
+
- ruby: "3.0"
|
24
|
+
puma: "5"
|
25
|
+
- ruby: "2.7"
|
26
|
+
puma: "5"
|
27
|
+
- ruby: "2.6"
|
28
|
+
puma: "4"
|
29
|
+
- ruby: "2.5"
|
30
|
+
puma: "4"
|
24
31
|
container:
|
25
32
|
image: ruby:${{ matrix.ruby }}
|
26
33
|
env:
|
27
34
|
CI: true
|
35
|
+
PUMA_VERSION: ${{ matrix.puma }}
|
28
36
|
steps:
|
29
|
-
- uses: actions/checkout@
|
30
|
-
- uses: actions/cache@
|
37
|
+
- uses: actions/checkout@v3
|
38
|
+
- uses: actions/cache@v3
|
31
39
|
with:
|
32
40
|
path: vendor/bundle
|
33
41
|
key: bundle-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}-${{ hashFiles('**/Gemfile') }}
|
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.7.0 - 2022-10-24
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- Puma 6.x support for `yabeda_prometheus` plugin. [@ollym][], [#25](https://github.com/yabeda-rb/yabeda-puma-plugin/pull/25)
|
13
|
+
- Support phased restarts with standalone Prometheus exporter. [@botimer][], [#23](https://github.com/yabeda-rb/yabeda-puma-plugin/pull/23)
|
14
|
+
- `on_prometheus_exporter_boot` hook in Puma config DSL. [@Envek][]
|
15
|
+
|
8
16
|
## 0.6.0 - 2021-02-05
|
9
17
|
|
10
18
|
### Changed
|
@@ -45,6 +53,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
45
53
|
|
46
54
|
Initial release with basic metrics collection. [@dsalahutdinov]
|
47
55
|
|
56
|
+
[@ollym]: https://github.com/ollym "Oliver Morgan"
|
48
57
|
[@botimer]: https://github.com/botimer "Noah Botimer"
|
49
58
|
[@jwhitcraft]: https://github.com/jwhitcraft "Jon Whitcraft"
|
50
59
|
[@Neznauy]: https://github.com/Neznauy "Aleksandr Shlyakov"
|
data/Gemfile
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
|
-
gem 'prometheus-client'
|
4
3
|
gem 'yabeda-prometheus'
|
4
|
+
|
5
5
|
# Specify your gem's dependencies in yabeda-puma.gemspec
|
6
6
|
gemspec
|
7
|
+
|
8
|
+
puma_version = ENV.fetch("PUMA_VERSION", "~> 6.0")
|
9
|
+
puma_version = "~> #{puma_version}.0" if puma_version.match?(/^\d+$/)
|
10
|
+
gem "puma", puma_version
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
alt="Sponsored by Amplifr" src="https://amplifr-direct.s3-eu-west-1.amazonaws.com/social_images/image/37b580d9-3668-4005-8d5a-137de3a3e77c.png" />
|
4
4
|
</a>
|
5
5
|
|
6
|
-
# Yabeda::Puma::Plugin
|
6
|
+
# ![`Yabeda::Puma::Plugin`](./yabeda-puma-plugin-logo.png)
|
7
7
|
|
8
8
|
Built-in metrics for [Puma](https://github.com/puma/puma) web server monitoring out of the box! Part of the [yabeda](https://github.com/yabeda-rb/yabeda) suite.
|
9
9
|
|
@@ -43,6 +43,17 @@ plugin :yabeda
|
|
43
43
|
```
|
44
44
|
It will activate default puma control application working over the unix socket, and runs the `yabeda` puma plugin, for registering and collecting the metrics.
|
45
45
|
|
46
|
+
> **Note**
|
47
|
+
>
|
48
|
+
> In case if you're **not** using Rails, don't forget configure Yabeda manually either in your app initialization or in Puma configuration hook:
|
49
|
+
> ```ruby
|
50
|
+
> # config/puma.rb
|
51
|
+
> before_fork do
|
52
|
+
> Yabeda.configure!
|
53
|
+
> end
|
54
|
+
> ```
|
55
|
+
> See [yabeda usage](https://github.com/yabeda-rb/yabeda#usage) for more information.
|
56
|
+
|
46
57
|
### Exposing metrics
|
47
58
|
|
48
59
|
Some monitoring system agents (like NewRelic or DataDog) will send metrics automatically in the background. But for some of monitoring systems (like Prometheus) you have to explicitly set up metrics export.
|
data/docker-compose.yml
CHANGED
@@ -14,6 +14,11 @@ module Puma
|
|
14
14
|
def prometheus_exporter_url(uri)
|
15
15
|
@options[:prometheus_exporter_url] = uri
|
16
16
|
end
|
17
|
+
|
18
|
+
def on_prometheus_exporter_boot(&block)
|
19
|
+
@options[:prometheus_exporter_boot_hooks] ||= []
|
20
|
+
@options[:prometheus_exporter_boot_hooks] << block
|
21
|
+
end
|
17
22
|
end
|
18
23
|
end
|
19
24
|
|
@@ -27,23 +32,67 @@ Puma::Plugin.create do
|
|
27
32
|
port = Integer(ENV.fetch('PROMETHEUS_EXPORTER_PORT', uri.port))
|
28
33
|
path = ENV.fetch('PROMETHEUS_EXPORTER_PATH', uri.path)
|
29
34
|
|
30
|
-
|
35
|
+
server = nil
|
36
|
+
logger = events
|
37
|
+
banner = "Yabeda Prometheus metrics exporter on http://#{host}:#{port}#{path}"
|
38
|
+
|
39
|
+
create_server = -> {
|
31
40
|
app = Yabeda::Prometheus::Exporter.rack_app(Yabeda::Prometheus::Exporter, path: path)
|
41
|
+
internal_events = Puma::Events.respond_to?(:null) ? Puma::Events.null : Puma::Events.new
|
42
|
+
server = Puma::Server.new app, internal_events, min_threads: 0, max_threads: 1
|
43
|
+
logger = server.respond_to?(:log_writer) ? server.log_writer : events
|
44
|
+
|
45
|
+
server.add_tcp_listener host, port
|
46
|
+
if server.respond_to?(:min_threads=)
|
47
|
+
server.min_threads = 0
|
48
|
+
server.max_threads = 1
|
49
|
+
end
|
32
50
|
|
33
|
-
|
34
|
-
|
35
|
-
|
51
|
+
internal_events.register(:state) do |state|
|
52
|
+
next unless state == :running
|
53
|
+
hooks = launcher.options.fetch(:prometheus_exporter_boot_hooks, [])
|
54
|
+
hooks.each(&:call)
|
55
|
+
end
|
36
56
|
|
37
|
-
|
38
|
-
|
57
|
+
[server, logger]
|
58
|
+
}
|
39
59
|
|
40
|
-
|
41
|
-
|
42
|
-
|
60
|
+
events.on_booted do
|
61
|
+
unless server&.running
|
62
|
+
server, logger = create_server.call
|
63
|
+
logger.log "* Starting #{banner}"
|
64
|
+
server.run
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# on_stopped and on_restart hooks were added in Puma 5.1 in https://github.com/puma/puma/commit/288a4cf756852a4837c77ee70d7fdcca1edb8e82
|
69
|
+
if events.respond_to?(:on_stopped) && events.respond_to?(:on_restart)
|
70
|
+
|
71
|
+
events.on_stopped do
|
72
|
+
unless server&.shutting_down?
|
73
|
+
logger.log "* Stopping #{banner}"
|
74
|
+
server.stop(true)
|
43
75
|
end
|
44
76
|
end
|
45
77
|
|
46
|
-
|
78
|
+
events.on_restart do
|
79
|
+
logger.log "* Restarting #{banner}"
|
80
|
+
server.stop(true)
|
81
|
+
server, logger = create_server.call
|
82
|
+
server.run
|
83
|
+
end
|
84
|
+
|
85
|
+
else
|
86
|
+
|
87
|
+
events.register(:state) do |state|
|
88
|
+
next unless %i[halt restart stop].include?(state)
|
89
|
+
|
90
|
+
metrics.stop(true) unless metrics.shutting_down?
|
91
|
+
next unless state == :restart
|
92
|
+
|
93
|
+
server, logger = create_server.call
|
94
|
+
server.run
|
95
|
+
end
|
47
96
|
end
|
48
97
|
end
|
49
98
|
end
|
Binary file
|
data/yabeda-puma-plugin.gemspec
CHANGED
@@ -28,5 +28,6 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency "bundler"
|
29
29
|
spec.add_development_dependency "rake", "~> 13.0"
|
30
30
|
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
-
spec.add_development_dependency "rack"
|
31
|
+
spec.add_development_dependency "rack", "< 3"
|
32
|
+
spec.add_development_dependency "yabeda-prometheus", "~> 0.8"
|
32
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yabeda-puma-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Salahutdinov Dmitry
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yabeda
|
@@ -98,16 +98,30 @@ dependencies:
|
|
98
98
|
name: rack
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "<"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '3'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "<"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '3'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: yabeda-prometheus
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.8'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.8'
|
111
125
|
description: Extends Yabeda metrics with puma web server values by using puma plugin
|
112
126
|
email:
|
113
127
|
- dsalahutdinov@gmail.com
|
@@ -137,6 +151,7 @@ files:
|
|
137
151
|
- lib/yabeda/puma/plugin/statistics/fetcher.rb
|
138
152
|
- lib/yabeda/puma/plugin/statistics/parser.rb
|
139
153
|
- lib/yabeda/puma/plugin/version.rb
|
154
|
+
- yabeda-puma-plugin-logo.png
|
140
155
|
- yabeda-puma-plugin.gemspec
|
141
156
|
homepage: http://github.com/yabeda-rb/yabeda-puma-plugin
|
142
157
|
licenses:
|
@@ -157,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
172
|
- !ruby/object:Gem::Version
|
158
173
|
version: '0'
|
159
174
|
requirements: []
|
160
|
-
rubygems_version: 3.1.
|
175
|
+
rubygems_version: 3.1.6
|
161
176
|
signing_key:
|
162
177
|
specification_version: 4
|
163
178
|
summary: Puma web server plugin for collecting puma metrics with Yabeda framework.
|