yabeda-puma-plugin 0.2.0 → 0.6.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/build-release.yml +82 -0
- data/.github/workflows/test.yml +45 -0
- data/CHANGELOG.md +52 -0
- data/README.md +80 -0
- data/lib/puma/plugin/yabeda.rb +8 -8
- data/lib/puma/plugin/yabeda_prometheus.rb +49 -0
- data/lib/yabeda/puma/plugin/statistics.rb +2 -2
- data/lib/yabeda/puma/plugin/statistics/fetcher.rb +13 -10
- data/lib/yabeda/puma/plugin/statistics/parser.rb +18 -6
- data/lib/yabeda/puma/plugin/version.rb +1 -1
- data/yabeda-puma-plugin.gemspec +2 -2
- metadata +13 -10
- data/.travis.yml +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e89900f2439ba78c8c813c423c1035133934fd7b727d355fe16be5416b40ef5
|
4
|
+
data.tar.gz: 1b99f6bebac908ad72fd85522b41823a42593262057cea0abb3c2c6dd9768501
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f586fcfa8cef7892afa68690c23cb6c73c70964bed54b0ce65d5434513490b91c133d2ef2e9709ad352dde50f6ebf1dea3c884e67b668737d8cfb0eb783c215
|
7
|
+
data.tar.gz: 97c8662a33acdd7102d90faa8725ee86269587c8c3f104dc49ae0621793c66e6f9f5ddf8660f0dbec11598e700dc97db32dcb51073c96384f4273baa20946ac6
|
@@ -0,0 +1,82 @@
|
|
1
|
+
name: Build and release gem to RubyGems
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- v*
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
release:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
with:
|
14
|
+
fetch-depth: 0 # Fetch current tag as annotated. See https://github.com/actions/checkout/issues/290
|
15
|
+
- uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: 2.7
|
18
|
+
- name: "Extract data from tag: version, message, body"
|
19
|
+
id: tag
|
20
|
+
run: |
|
21
|
+
git fetch --tags --force # Really fetch annotated tag. See https://github.com/actions/checkout/issues/290#issuecomment-680260080
|
22
|
+
echo ::set-output name=version::${GITHUB_REF#refs/tags/v}
|
23
|
+
echo ::set-output name=subject::$(git for-each-ref $GITHUB_REF --format='%(contents:subject)')
|
24
|
+
# Extract changelog entries between this and previous version headers
|
25
|
+
escaped_version=$(echo ${GITHUB_REF#refs/tags/v} | sed -e 's/[]\/$*.^[]/\\&/g')
|
26
|
+
changelog=$(awk "BEGIN{inrelease=0} /## ${escaped_version}/{inrelease=1;next} /## [0-9]+\.[0-9]+\.[0-9]+/{inrelease=0;exit} {if (inrelease) print}" CHANGELOG.md)
|
27
|
+
# Multiline body for release. See https://github.community/t/set-output-truncates-multiline-strings/16852/5
|
28
|
+
BODY="$(git for-each-ref $GITHUB_REF --format='%(contents:body)')"
|
29
|
+
BODY="${BODY}"$'\n'"${changelog}"
|
30
|
+
BODY="${BODY//'%'/'%25'}"
|
31
|
+
BODY="${BODY//$'\n'/'%0A'}"
|
32
|
+
BODY="${BODY//$'\r'/'%0D'}"
|
33
|
+
echo "::set-output name=body::$BODY"
|
34
|
+
# Add pre-release option if tag name has any suffix after vMAJOR.MINOR.PATCH
|
35
|
+
if [[ ${GITHUB_REF#refs/tags/} =~ ^v[0-9]+\.[0-9]+\.[0-9]+.+ ]]; then
|
36
|
+
echo ::set-output name=prerelease::true
|
37
|
+
fi
|
38
|
+
- name: Build gem
|
39
|
+
run: gem build
|
40
|
+
- name: Calculate checksums
|
41
|
+
run: sha256sum yabeda-puma-plugin-${{ steps.tag.outputs.version }}.gem > SHA256SUM
|
42
|
+
- name: Check version
|
43
|
+
run: ls -l yabeda-puma-plugin-${{ steps.tag.outputs.version }}.gem
|
44
|
+
- name: Create Release
|
45
|
+
id: create_release
|
46
|
+
uses: actions/create-release@v1
|
47
|
+
env:
|
48
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
49
|
+
with:
|
50
|
+
tag_name: ${{ github.ref }}
|
51
|
+
release_name: ${{ steps.tag.outputs.subject }}
|
52
|
+
body: ${{ steps.tag.outputs.body }}
|
53
|
+
draft: false
|
54
|
+
prerelease: ${{ steps.tag.outputs.prerelease }}
|
55
|
+
- name: Upload built gem as release asset
|
56
|
+
uses: actions/upload-release-asset@v1
|
57
|
+
env:
|
58
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
59
|
+
with:
|
60
|
+
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
61
|
+
asset_path: yabeda-puma-plugin-${{ steps.tag.outputs.version }}.gem
|
62
|
+
asset_name: yabeda-puma-plugin-${{ steps.tag.outputs.version }}.gem
|
63
|
+
asset_content_type: application/x-tar
|
64
|
+
- name: Upload checksums as release asset
|
65
|
+
uses: actions/upload-release-asset@v1
|
66
|
+
env:
|
67
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
68
|
+
with:
|
69
|
+
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
70
|
+
asset_path: SHA256SUM
|
71
|
+
asset_name: SHA256SUM
|
72
|
+
asset_content_type: text/plain
|
73
|
+
- name: Publish to GitHub packages
|
74
|
+
env:
|
75
|
+
GEM_HOST_API_KEY: Bearer ${{ secrets.GITHUB_TOKEN }}
|
76
|
+
run: |
|
77
|
+
gem push yabeda-puma-plugin-${{ steps.tag.outputs.version }}.gem --host https://rubygems.pkg.github.com/${{ github.repository_owner }}
|
78
|
+
- name: Publish to RubyGems
|
79
|
+
env:
|
80
|
+
GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_API_KEY }}"
|
81
|
+
run: |
|
82
|
+
gem push yabeda-puma-plugin-${{ steps.tag.outputs.version }}.gem
|
@@ -0,0 +1,45 @@
|
|
1
|
+
name: Run tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- '**'
|
8
|
+
tags-ignore:
|
9
|
+
- 'v*'
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
test:
|
13
|
+
name: "Run tests"
|
14
|
+
if: "! contains(toJSON(github.event.commits.latest.message), '[ci skip]')"
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
strategy:
|
17
|
+
fail-fast: false
|
18
|
+
matrix:
|
19
|
+
include:
|
20
|
+
- ruby: 3.0
|
21
|
+
- ruby: 2.7
|
22
|
+
- ruby: 2.6
|
23
|
+
- ruby: 2.5
|
24
|
+
container:
|
25
|
+
image: ruby:${{ matrix.ruby }}
|
26
|
+
env:
|
27
|
+
CI: true
|
28
|
+
steps:
|
29
|
+
- uses: actions/checkout@v2
|
30
|
+
- uses: actions/cache@v2
|
31
|
+
with:
|
32
|
+
path: vendor/bundle
|
33
|
+
key: bundle-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}-${{ hashFiles('**/Gemfile') }}
|
34
|
+
restore-keys: |
|
35
|
+
bundle-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}-${{ hashFiles('**/Gemfile') }}
|
36
|
+
bundle-${{ matrix.ruby }}-
|
37
|
+
- name: Upgrade Bundler to 2.0 (for older Rubies)
|
38
|
+
run: gem install bundler -v '~> 2.0'
|
39
|
+
- name: Bundle install
|
40
|
+
run: |
|
41
|
+
bundle config path vendor/bundle
|
42
|
+
bundle install
|
43
|
+
bundle update
|
44
|
+
- name: Run RSpec
|
45
|
+
run: bundle exec rspec
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,52 @@
|
|
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
|
+
## 0.6.0 - 2021-02-05
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- “Most recent” aggregation mode specified for all gauge metrics. [@botimer], [#16](https://github.com/yabeda-rb/yabeda-puma-plugin/pull/16)
|
13
|
+
|
14
|
+
## 0.5.0 - 2020-11-13
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
|
18
|
+
- Start Yabeda exporter on `on_booted` hook to support Puma 4.x daemon mode. [@Envek], [#14](https://github.com/yabeda-rb/yabeda-puma-plugin/pull/14)
|
19
|
+
|
20
|
+
## 0.4.0 - 2020-04-29
|
21
|
+
|
22
|
+
### Added
|
23
|
+
|
24
|
+
- `yabeda_prometheus` plugin to allow metrics export on separate port. [@jwhitcraft], [#11](https://github.com/yabeda-rb/yabeda-puma-plugin/pull/11)
|
25
|
+
|
26
|
+
## 0.3.0 - 2020-01-27
|
27
|
+
|
28
|
+
### Added
|
29
|
+
|
30
|
+
- Support for yabeda 0.2 (required by prometheus-client 1.0). [@Envek]
|
31
|
+
|
32
|
+
## 0.2.1 - 2019-12-16
|
33
|
+
|
34
|
+
### Fixed
|
35
|
+
|
36
|
+
- Fix undefined method in TCP socket. [@Neznauy], [#7](https://github.com/yabeda-rb/yabeda-puma-plugin/pull/7)
|
37
|
+
|
38
|
+
## 0.2.0 - 2019-12-12
|
39
|
+
|
40
|
+
### Added
|
41
|
+
|
42
|
+
- Support for TCP puma control panel url. [@dsalahutdinov]
|
43
|
+
|
44
|
+
## 0.1.0 - 2019-04-02
|
45
|
+
|
46
|
+
Initial release with basic metrics collection. [@dsalahutdinov]
|
47
|
+
|
48
|
+
[@botimer]: https://github.com/botimer "Noah Botimer"
|
49
|
+
[@jwhitcraft]: https://github.com/jwhitcraft "Jon Whitcraft"
|
50
|
+
[@Neznauy]: https://github.com/Neznauy "Aleksandr Shlyakov"
|
51
|
+
[@Envek]: https://github.com/Envek "Andrey Novikov"
|
52
|
+
[@dsalahutdinov]: https://github.com/dsalahutdinov "Dmitry Salahutdinov"
|
data/README.md
CHANGED
@@ -34,6 +34,8 @@ And then execute:
|
|
34
34
|
|
35
35
|
## Usage
|
36
36
|
|
37
|
+
### Collecting metrics
|
38
|
+
|
37
39
|
Add those 2 lines of code to your `config/puma.rb` file:
|
38
40
|
```ruby
|
39
41
|
activate_control_app
|
@@ -41,6 +43,52 @@ plugin :yabeda
|
|
41
43
|
```
|
42
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.
|
43
45
|
|
46
|
+
### Exposing metrics
|
47
|
+
|
48
|
+
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.
|
49
|
+
|
50
|
+
#### Prometheus
|
51
|
+
|
52
|
+
##### On the same endpoint with your application
|
53
|
+
|
54
|
+
For non-Rails applications place following line in your `config.ru` _before_ running your application:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
use Yabeda::Prometheus::Exporter, path: "/metrics"
|
58
|
+
```
|
59
|
+
|
60
|
+
In Ruby on Rails applications you can add following line in `config/routes.rb` instead:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
mount Yabeda::Prometheus::Exporter => "/metrics"
|
64
|
+
```
|
65
|
+
|
66
|
+
In both cases your Puma instance metrics (along with your application metrics) will be available at `/metrics` endpoint.
|
67
|
+
|
68
|
+
##### On different port
|
69
|
+
|
70
|
+
Sometimes you don't want to expose metrics publicly for security reasons. For that case prometheus exporter plugin is bundled with this gem.
|
71
|
+
|
72
|
+
Don't forget to add either `yabeda-prometheus` or `yabeda-prometheus-mmap` gem into your `Gemfile`!
|
73
|
+
|
74
|
+
Add this plugin into your `config/puma.rb`:
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
plugin :yabeda_prometheus
|
78
|
+
```
|
79
|
+
|
80
|
+
By default metrics will be available at `http://0.0.0.0:9394/metrics`.
|
81
|
+
|
82
|
+
Bind host, port, and path can be controlled either by config file option `prometheus_exporter_url`:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
# config/puma.rb
|
86
|
+
prometheus_exporter_url "tcp://127.0.0.1:9395/shmetrics"
|
87
|
+
```
|
88
|
+
|
89
|
+
Or by environment variables `PROMETHEUS_EXPORTER_URL`, `PROMETHEUS_EXPORTER_BIND`, `PROMETHEUS_EXPORTER_PORT`, and `PROMETHEUS_EXPORTER_PATH` (takes precedence over configuration option).
|
90
|
+
|
91
|
+
|
44
92
|
## Details
|
45
93
|
|
46
94
|
In accordance with the [architecture](https://github.com/puma/puma/blob/master/docs/architecture.md) of the puma web server lets look how it works:
|
@@ -86,6 +134,38 @@ docker-compose run app bundle exec rspec
|
|
86
134
|
|
87
135
|
Bug reports and pull requests are welcome on GitHub at https://github.com/yabeda-rb/yabeda-puma-plugin.
|
88
136
|
|
137
|
+
### Releasing
|
138
|
+
|
139
|
+
1. Bump version number in `lib/yabeda/puma/plugin/version.rb`
|
140
|
+
|
141
|
+
In case of pre-releases keep in mind [rubygems/rubygems#3086](https://github.com/rubygems/rubygems/issues/3086) and check version with command like `Gem::Version.new(Yabeda::VERSION).to_s`
|
142
|
+
|
143
|
+
2. Fill `CHANGELOG.md` with missing changes, add header with version and date.
|
144
|
+
|
145
|
+
3. Make a commit:
|
146
|
+
|
147
|
+
```sh
|
148
|
+
git add lib/yabeda/puma/plugin/version.rb CHANGELOG.md
|
149
|
+
version=$(ruby -r ./lib/yabeda/puma/plugin/version.rb -e "puts Gem::Version.new(Yabeda::Puma::Plugin::VERSION)")
|
150
|
+
git commit --message="${version}: " --edit
|
151
|
+
```
|
152
|
+
|
153
|
+
4. Create annotated tag:
|
154
|
+
|
155
|
+
```sh
|
156
|
+
git tag v${version} --annotate --message="${version}: " --edit --sign
|
157
|
+
```
|
158
|
+
|
159
|
+
5. Fill version name into subject line and (optionally) some description (list of changes will be taken from changelog and appended automatically)
|
160
|
+
|
161
|
+
6. Push it:
|
162
|
+
|
163
|
+
```sh
|
164
|
+
git push --follow-tags
|
165
|
+
```
|
166
|
+
|
167
|
+
7. GitHub Actions will create a new release, build and push gem into RubyGems! You're done!
|
168
|
+
|
89
169
|
## License
|
90
170
|
|
91
171
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/puma/plugin/yabeda.rb
CHANGED
@@ -14,16 +14,16 @@ Puma::Plugin.create do
|
|
14
14
|
|
15
15
|
Yabeda.configure do
|
16
16
|
group :puma
|
17
|
-
|
18
|
-
gauge :backlog, comment: 'Number of established but unaccepted connections in the backlog'
|
19
|
-
gauge :running, comment: 'Number of running worker threads'
|
20
|
-
gauge :pool_capacity, comment: 'Number of allocatable worker threads'
|
21
|
-
gauge :max_threads, comment: 'Maximum number of worker threads'
|
22
|
-
gauge :workers, comment: 'Number of configured workers'
|
17
|
+
|
18
|
+
gauge :backlog, tags: %i[index], comment: 'Number of established but unaccepted connections in the backlog', aggregation: :most_recent
|
19
|
+
gauge :running, tags: %i[index], comment: 'Number of running worker threads', aggregation: :most_recent
|
20
|
+
gauge :pool_capacity, tags: %i[index], comment: 'Number of allocatable worker threads', aggregation: :most_recent
|
21
|
+
gauge :max_threads, tags: %i[index], comment: 'Maximum number of worker threads', aggregation: :most_recent
|
23
22
|
|
24
23
|
if clustered
|
25
|
-
gauge :
|
26
|
-
gauge :
|
24
|
+
gauge :workers, comment: 'Number of configured workers', aggregation: :most_recent
|
25
|
+
gauge :booted_workers, comment: 'Number of booted workers', aggregation: :most_recent
|
26
|
+
gauge :old_workers, comment: 'Number of old workers', aggregation: :most_recent
|
27
27
|
end
|
28
28
|
|
29
29
|
collect do
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'yabeda/prometheus/exporter'
|
5
|
+
rescue LoadError
|
6
|
+
raise LoadError, 'Please add either yabeda-prometheus or yabeda-prometheus-mmap gem into your Gemfile to use yabeda/prometheus/exporter!'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'uri'
|
10
|
+
require 'rack'
|
11
|
+
|
12
|
+
module Puma
|
13
|
+
class DSL
|
14
|
+
def prometheus_exporter_url(uri)
|
15
|
+
@options[:prometheus_exporter_url] = uri
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Puma::Plugin.create do
|
21
|
+
def start(launcher)
|
22
|
+
events = launcher.events
|
23
|
+
|
24
|
+
uri = launcher.options.fetch(:prometheus_exporter_url, 'tcp://0.0.0.0:9394/metrics')
|
25
|
+
uri = URI.parse(ENV.fetch('PROMETHEUS_EXPORTER_URL', uri))
|
26
|
+
host = ENV.fetch('PROMETHEUS_EXPORTER_BIND', uri.host)
|
27
|
+
port = Integer(ENV.fetch('PROMETHEUS_EXPORTER_PORT', uri.port))
|
28
|
+
path = ENV.fetch('PROMETHEUS_EXPORTER_PATH', uri.path)
|
29
|
+
|
30
|
+
events.on_booted do
|
31
|
+
app = Yabeda::Prometheus::Exporter.rack_app(Yabeda::Prometheus::Exporter, path: path)
|
32
|
+
|
33
|
+
metrics = Puma::Server.new app, events
|
34
|
+
metrics.min_threads = 0
|
35
|
+
metrics.max_threads = 1
|
36
|
+
|
37
|
+
events.log "* Starting Yabeda Prometheus metrics exporter on http://#{host}:#{port}#{path}"
|
38
|
+
metrics.add_tcp_listener host, port
|
39
|
+
|
40
|
+
events.register(:state) do |state|
|
41
|
+
if %i[halt restart stop].include?(state)
|
42
|
+
metrics.stop(true) unless metrics.shutting_down?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
metrics.run
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -2,8 +2,8 @@ module Yabeda
|
|
2
2
|
module Puma
|
3
3
|
module Plugin
|
4
4
|
module Statistics
|
5
|
-
METRICS = [:backlog, :running, :pool_capacity, :max_threads
|
6
|
-
CLUSTERED_METRICS = [:booted_workers, :old_workers]
|
5
|
+
METRICS = [:backlog, :running, :pool_capacity, :max_threads]
|
6
|
+
CLUSTERED_METRICS = [:booted_workers, :old_workers, :workers]
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -9,24 +9,27 @@ module Yabeda
|
|
9
9
|
def self.call
|
10
10
|
control_url = Yabeda::Puma::Plugin.control_url
|
11
11
|
|
12
|
-
if control_url.start_with? "unix://"
|
12
|
+
body = if control_url.start_with? "unix://"
|
13
13
|
path = control_url.gsub("unix://", '')
|
14
|
-
|
14
|
+
Socket.unix(path, &socket_block)
|
15
15
|
elsif control_url.start_with? "tcp://"
|
16
16
|
host, port = control_url.match(/^tcp:\/\/([a-z0-9\-._~%]+):([0-9]+)/).captures
|
17
|
-
|
18
|
-
sock = Socket.tcp(host, port)
|
17
|
+
Socket.tcp(host, port, &socket_block)
|
19
18
|
else
|
20
|
-
raise ArgumentError("Unknown puma control url type #{control_url}")
|
21
|
-
end
|
22
|
-
|
23
|
-
body = sock do |socket|
|
24
|
-
socket << "GET /stats?token=#{Yabeda::Puma::Plugin.control_auth_token} HTTP/1.0\r\n\r\n"
|
25
|
-
socket.read
|
19
|
+
raise ArgumentError.new("Unknown puma control url type #{control_url}")
|
26
20
|
end
|
27
21
|
|
28
22
|
JSON.parse(body.split("\n").last)
|
29
23
|
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def self.socket_block
|
28
|
+
Proc.new do |s|
|
29
|
+
s << "GET /stats?token=#{Yabeda::Puma::Plugin.control_auth_token} HTTP/1.0\r\n\r\n"
|
30
|
+
s.read
|
31
|
+
end
|
32
|
+
end
|
30
33
|
end
|
31
34
|
end
|
32
35
|
end
|
@@ -13,21 +13,33 @@ module Yabeda
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def call
|
16
|
-
|
16
|
+
[].tap { |result| parse(data, {}, result) }
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
-
def parse(stats, labels
|
21
|
+
def parse(stats, labels, result)
|
22
22
|
stats.each do |key, value|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
case key
|
24
|
+
when 'worker_status'
|
25
|
+
value.each { |s| parse(s, labels.merge(index: s['index']), result) }
|
26
|
+
when 'last_status'
|
27
|
+
parse(value, labels, result)
|
28
|
+
else
|
29
|
+
next unless metric?(key)
|
30
|
+
|
31
|
+
l = clustered_metric?(key) ? labels : { index: 0 }.merge(labels)
|
32
|
+
result << { name: key, value: value, labels: l }
|
33
|
+
end
|
26
34
|
end
|
27
35
|
end
|
28
36
|
|
29
37
|
def metric?(name)
|
30
|
-
Statistics::METRICS.include?(name.to_sym) ||
|
38
|
+
Statistics::METRICS.include?(name.to_sym) || clustered_metric?(name)
|
39
|
+
end
|
40
|
+
|
41
|
+
def clustered_metric?(name)
|
42
|
+
clustered && Statistics::CLUSTERED_METRICS.include?(name.to_sym)
|
31
43
|
end
|
32
44
|
end
|
33
45
|
end
|
data/yabeda-puma-plugin.gemspec
CHANGED
@@ -21,12 +21,12 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_runtime_dependency "yabeda"
|
24
|
+
spec.add_runtime_dependency "yabeda", "~> 0.5"
|
25
25
|
spec.add_runtime_dependency "puma"
|
26
26
|
spec.add_runtime_dependency "json"
|
27
27
|
|
28
28
|
spec.add_development_dependency "bundler"
|
29
|
-
spec.add_development_dependency "rake", "~>
|
29
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
30
30
|
spec.add_development_dependency "rspec", "~> 3.0"
|
31
31
|
spec.add_development_dependency "rack"
|
32
32
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
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.6.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: 2021-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yabeda
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '0.5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '0.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: puma
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '13.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '13.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,9 +115,11 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
+
- ".github/workflows/build-release.yml"
|
119
|
+
- ".github/workflows/test.yml"
|
118
120
|
- ".gitignore"
|
119
121
|
- ".rspec"
|
120
|
-
-
|
122
|
+
- CHANGELOG.md
|
121
123
|
- Gemfile
|
122
124
|
- LICENSE
|
123
125
|
- LICENSE.txt
|
@@ -129,6 +131,7 @@ files:
|
|
129
131
|
- docs/diagram.png
|
130
132
|
- docs/grafana.png
|
131
133
|
- lib/puma/plugin/yabeda.rb
|
134
|
+
- lib/puma/plugin/yabeda_prometheus.rb
|
132
135
|
- lib/yabeda/puma/plugin.rb
|
133
136
|
- lib/yabeda/puma/plugin/statistics.rb
|
134
137
|
- lib/yabeda/puma/plugin/statistics/fetcher.rb
|
@@ -154,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
157
|
- !ruby/object:Gem::Version
|
155
158
|
version: '0'
|
156
159
|
requirements: []
|
157
|
-
rubygems_version: 3.
|
160
|
+
rubygems_version: 3.1.4
|
158
161
|
signing_key:
|
159
162
|
specification_version: 4
|
160
163
|
summary: Puma web server plugin for collecting puma metrics with Yabeda framework.
|