puma-plugin-telemetry 1.1.1 → 1.1.4
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/.tool-versions +1 -1
- data/CHANGELOG.md +19 -0
- data/README.md +13 -9
- data/lib/puma/plugin/telemetry/version.rb +1 -1
- data/lib/puma/plugin/telemetry.rb +16 -5
- data/puma-plugin-telemetry.gemspec +5 -2
- metadata +7 -14
- data/.github/CODEOWNERS +0 -6
- data/.github/workflows/build.yml +0 -63
- data/.gitignore +0 -11
- data/Gemfile +0 -14
- data/Gemfile.lock +0 -67
- data/bin/console +0 -15
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8f6637e84f006fba6caefa5187fcd41670978d92272702e70c2f93f4f146660
|
4
|
+
data.tar.gz: 1114593461807d980f4f8070e02d0a9ccafd60be819aae580d33924e3b0617c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b6a6aa3e7bb56b54a40f01ced4d3b228ae0ccd94195a460307b13ebff6a3f4fe3f13ec748d5486d9878691c7696aadd1aeafa84b02baa9b232772e5e21e405b
|
7
|
+
data.tar.gz: fb02f9fc3f1e278ed8e72f745a9153a54537bafd8a1e0e28035caf7ac1dc29102f7c8c66250145b325ec6c0c174de7146ad84451773ca44321f4b086044ef321
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 2.6.
|
1
|
+
ruby 2.6.10
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [1.1.4]
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
- Updated gems in the lockfile
|
14
|
+
|
15
|
+
## [1.1.3]
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
- Updated gems in the lockfile
|
19
|
+
|
20
|
+
### Added
|
21
|
+
- Support for Ruby 3.2 and 3.3
|
22
|
+
|
23
|
+
### Dropped
|
24
|
+
- Check for support for 'ubuntu-18.04'
|
25
|
+
|
26
|
+
## [1.1.2]
|
27
|
+
|
28
|
+
- Add Puma 6 compatibility
|
10
29
|
## [1.1.1]
|
11
30
|
|
12
31
|
Public release.
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Puma plugin which should be able to handle all your metric needs regarding your webserver:
|
4
4
|
|
5
|
-
- ability to publish basic puma statistics (like queue backlog) to both logs and
|
5
|
+
- ability to publish basic puma statistics (like queue backlog) to both logs and Datadog
|
6
6
|
- ability to add custom target whenever you need it
|
7
7
|
- ability to monitor puma socket listen queue (!)
|
8
8
|
- ability to report requests queue time via custom rack middleware - the time request spent between being accepted by Load Balancer and start of its processing by Puma worker
|
@@ -17,11 +17,15 @@ gem "puma-plugin-telemetry"
|
|
17
17
|
|
18
18
|
And then execute:
|
19
19
|
|
20
|
-
|
20
|
+
```console
|
21
|
+
$ bundle install
|
22
|
+
```
|
21
23
|
|
22
24
|
Or install it yourself as:
|
23
25
|
|
24
|
-
|
26
|
+
```console
|
27
|
+
$ gem install puma-plugin-telemetry
|
28
|
+
```
|
25
29
|
|
26
30
|
## Usage
|
27
31
|
|
@@ -39,15 +43,15 @@ end
|
|
39
43
|
|
40
44
|
### Basic
|
41
45
|
|
42
|
-
Output telemetry as JSON to STDOUT
|
46
|
+
Output telemetry as JSON to `STDOUT`
|
43
47
|
|
44
48
|
```ruby
|
45
49
|
config.add_target :io
|
46
50
|
```
|
47
51
|
|
48
|
-
### Datadog
|
52
|
+
### Datadog StatsD target
|
49
53
|
|
50
|
-
Given gem provides built in target for Datadog
|
54
|
+
Given gem provides built in target for Datadog StatsD client, that uses batch operation to publish metrics.
|
51
55
|
|
52
56
|
**NOTE** Be sure to have `dogstatsd` gem installed.
|
53
57
|
|
@@ -76,7 +80,7 @@ end
|
|
76
80
|
|
77
81
|
### Custom Targets
|
78
82
|
|
79
|
-
Target is a simple object that implements `call` methods that accepts `telemetry` hash object. This means it can be super simple `proc` or some
|
83
|
+
Target is a simple object that implements `call` methods that accepts `telemetry` hash object. This means it can be super simple `proc` or some sophisticated class calling some external API.
|
80
84
|
|
81
85
|
Just be mindful that if the API takes long to call, it will slow down frequency with which telemetry will get reported.
|
82
86
|
|
@@ -87,7 +91,7 @@ Just be mindful that if the API takes long to call, it will slow down frequency
|
|
87
91
|
|
88
92
|
## Extra middleware
|
89
93
|
|
90
|
-
This gems comes together with middleware for measuring request queue time, which will be reported in `request.env` and published to given
|
94
|
+
This gems comes together with middleware for measuring request queue time, which will be reported in `request.env` and published to given StatsD client.
|
91
95
|
|
92
96
|
Example configuration:
|
93
97
|
|
@@ -110,7 +114,7 @@ This will provide proper metric in Datadog and in logs as well. Logs can be tran
|
|
110
114
|
|
111
115
|
## Development
|
112
116
|
|
113
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
117
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
114
118
|
|
115
119
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
116
120
|
|
@@ -63,13 +63,14 @@ module Puma
|
|
63
63
|
#
|
64
64
|
module PluginInstanceMethods
|
65
65
|
def start(launcher)
|
66
|
+
@launcher = launcher
|
67
|
+
|
66
68
|
unless Puma::Plugin::Telemetry.config.enabled?
|
67
|
-
|
69
|
+
log_writer.log 'plugin=telemetry msg="disabled, exiting..."'
|
68
70
|
return
|
69
71
|
end
|
70
72
|
|
71
|
-
|
72
|
-
@launcher.events.log 'plugin=telemetry msg="enabled, setting up runner..."'
|
73
|
+
log_writer.log 'plugin=telemetry msg="enabled, setting up runner..."'
|
73
74
|
|
74
75
|
in_background do
|
75
76
|
sleep Puma::Plugin::Telemetry.config.initial_delay
|
@@ -79,13 +80,13 @@ module Puma
|
|
79
80
|
|
80
81
|
def run!
|
81
82
|
loop do
|
82
|
-
|
83
|
+
log_writer.debug 'plugin=telemetry msg="publish"'
|
83
84
|
|
84
85
|
call(Puma::Plugin::Telemetry.build(@launcher))
|
85
86
|
rescue Errno::EPIPE
|
86
87
|
# Occurs when trying to output to STDOUT while puma is shutting down
|
87
88
|
rescue StandardError => e
|
88
|
-
|
89
|
+
log_writer.error "plugin=telemetry err=#{e.class} msg=#{e.message.inspect}"
|
89
90
|
ensure
|
90
91
|
sleep Puma::Plugin::Telemetry.config.frequency
|
91
92
|
end
|
@@ -96,6 +97,16 @@ module Puma
|
|
96
97
|
target.call(telemetry)
|
97
98
|
end
|
98
99
|
end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
def log_writer
|
104
|
+
if Puma::Const::PUMA_VERSION.to_i < 6
|
105
|
+
@launcher.events
|
106
|
+
else
|
107
|
+
@launcher.log_writer
|
108
|
+
end
|
109
|
+
end
|
99
110
|
end
|
100
111
|
end
|
101
112
|
end
|
@@ -33,11 +33,14 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
33
33
|
# Specify which files should be added to the gem when it is released.
|
34
34
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
35
35
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
36
|
-
`git ls-files -z`.split("\x0").reject
|
36
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
37
|
+
(File.expand_path(f) == __FILE__) ||
|
38
|
+
f.start_with?(*%w[bin/ spec/ .git .github Gemfile])
|
39
|
+
end
|
37
40
|
end
|
38
41
|
spec.bindir = 'exe'
|
39
42
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
40
43
|
spec.require_paths = ['lib']
|
41
44
|
|
42
|
-
spec.add_dependency 'puma', '
|
45
|
+
spec.add_dependency 'puma', '< 7'
|
43
46
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puma-plugin-telemetry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leszek Zalewski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puma
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '7'
|
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: '
|
26
|
+
version: '7'
|
27
27
|
description: |
|
28
28
|
Puma plugin which should be able to handle all your metric needs regarding your webserver:
|
29
29
|
|
@@ -37,21 +37,14 @@ executables: []
|
|
37
37
|
extensions: []
|
38
38
|
extra_rdoc_files: []
|
39
39
|
files:
|
40
|
-
- ".github/CODEOWNERS"
|
41
|
-
- ".github/workflows/build.yml"
|
42
|
-
- ".gitignore"
|
43
40
|
- ".rspec"
|
44
41
|
- ".rubocop.yml"
|
45
42
|
- ".tool-versions"
|
46
43
|
- CHANGELOG.md
|
47
44
|
- CODE_OF_CONDUCT.md
|
48
|
-
- Gemfile
|
49
|
-
- Gemfile.lock
|
50
45
|
- LICENSE.txt
|
51
46
|
- README.md
|
52
47
|
- Rakefile
|
53
|
-
- bin/console
|
54
|
-
- bin/setup
|
55
48
|
- docs/example-datadog_backlog_size.png
|
56
49
|
- docs/example-datadog_queue_time.png
|
57
50
|
- docs/examples.md
|
@@ -87,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
80
|
- !ruby/object:Gem::Version
|
88
81
|
version: '0'
|
89
82
|
requirements: []
|
90
|
-
rubygems_version: 3.0.3
|
83
|
+
rubygems_version: 3.0.3.1
|
91
84
|
signing_key:
|
92
85
|
specification_version: 4
|
93
86
|
summary: Puma plugin, adding ability to publish various metrics to your prefered targets.
|
data/.github/CODEOWNERS
DELETED
data/.github/workflows/build.yml
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
name: build
|
2
|
-
|
3
|
-
on: [push, create]
|
4
|
-
|
5
|
-
jobs:
|
6
|
-
build_matrix:
|
7
|
-
strategy:
|
8
|
-
matrix:
|
9
|
-
os: ['ubuntu-18.04', 'ubuntu-20.04']
|
10
|
-
ruby: ['2.6', '2.7', '3.0', '3.1']
|
11
|
-
|
12
|
-
runs-on: ${{ matrix.os }}
|
13
|
-
|
14
|
-
steps:
|
15
|
-
# Environment setup
|
16
|
-
- uses: actions/checkout@v3
|
17
|
-
|
18
|
-
- uses: ruby/setup-ruby@v1
|
19
|
-
with:
|
20
|
-
ruby-version: ${{ matrix.ruby }}
|
21
|
-
bundler-cache: true
|
22
|
-
|
23
|
-
- name: Run rubocop
|
24
|
-
run: |
|
25
|
-
bundle exec rubocop --display-cop-names
|
26
|
-
|
27
|
-
- name: Run tests
|
28
|
-
run: |
|
29
|
-
bundle exec rspec
|
30
|
-
|
31
|
-
build:
|
32
|
-
needs: [build_matrix]
|
33
|
-
runs-on: ubuntu-20.04
|
34
|
-
steps:
|
35
|
-
- name: Dummy for branch status checks
|
36
|
-
run: |
|
37
|
-
echo "build complete"
|
38
|
-
|
39
|
-
release:
|
40
|
-
runs-on: ubuntu-20.04
|
41
|
-
|
42
|
-
needs:
|
43
|
-
- build
|
44
|
-
|
45
|
-
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v')
|
46
|
-
|
47
|
-
steps:
|
48
|
-
- uses: actions/checkout@v3
|
49
|
-
- uses: ruby/setup-ruby@v1
|
50
|
-
|
51
|
-
- name: Create credentials
|
52
|
-
run: |
|
53
|
-
mkdir -p ~/.gem
|
54
|
-
cat << EOF > ~/.gem/credentials
|
55
|
-
---
|
56
|
-
:rubygems_api_key: ${{ secrets.RUBYGEMS_TOKEN }}
|
57
|
-
EOF
|
58
|
-
chmod 0600 /home/runner/.gem/credentials
|
59
|
-
|
60
|
-
- name: Publish gem
|
61
|
-
run: |
|
62
|
-
gem build puma-plugin-telemetry.gemspec
|
63
|
-
gem push puma-plugin-telemetry-*.gem
|
data/.gitignore
DELETED
data/Gemfile
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in puma-plugin-telemetry.gemspec
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
gem 'dogstatsd-ruby'
|
9
|
-
|
10
|
-
gem 'rack'
|
11
|
-
gem 'rake', '~> 12.0'
|
12
|
-
gem 'rspec', '~> 3.0'
|
13
|
-
gem 'rubocop', '~> 1.5'
|
14
|
-
gem 'rubocop-performance', '~> 1.9'
|
data/Gemfile.lock
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
puma-plugin-telemetry (1.1.1)
|
5
|
-
puma (>= 5.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
ast (2.4.2)
|
11
|
-
diff-lcs (1.5.0)
|
12
|
-
dogstatsd-ruby (5.5.0)
|
13
|
-
nio4r (2.5.8)
|
14
|
-
parallel (1.22.1)
|
15
|
-
parser (3.1.2.0)
|
16
|
-
ast (~> 2.4.1)
|
17
|
-
puma (5.6.4)
|
18
|
-
nio4r (~> 2.0)
|
19
|
-
rack (2.2.3.1)
|
20
|
-
rainbow (3.1.1)
|
21
|
-
rake (12.3.3)
|
22
|
-
regexp_parser (2.5.0)
|
23
|
-
rexml (3.2.5)
|
24
|
-
rspec (3.11.0)
|
25
|
-
rspec-core (~> 3.11.0)
|
26
|
-
rspec-expectations (~> 3.11.0)
|
27
|
-
rspec-mocks (~> 3.11.0)
|
28
|
-
rspec-core (3.11.0)
|
29
|
-
rspec-support (~> 3.11.0)
|
30
|
-
rspec-expectations (3.11.0)
|
31
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
-
rspec-support (~> 3.11.0)
|
33
|
-
rspec-mocks (3.11.1)
|
34
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
-
rspec-support (~> 3.11.0)
|
36
|
-
rspec-support (3.11.0)
|
37
|
-
rubocop (1.30.1)
|
38
|
-
parallel (~> 1.10)
|
39
|
-
parser (>= 3.1.0.0)
|
40
|
-
rainbow (>= 2.2.2, < 4.0)
|
41
|
-
regexp_parser (>= 1.8, < 3.0)
|
42
|
-
rexml (>= 3.2.5, < 4.0)
|
43
|
-
rubocop-ast (>= 1.18.0, < 2.0)
|
44
|
-
ruby-progressbar (~> 1.7)
|
45
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
46
|
-
rubocop-ast (1.18.0)
|
47
|
-
parser (>= 3.1.1.0)
|
48
|
-
rubocop-performance (1.14.2)
|
49
|
-
rubocop (>= 1.7.0, < 2.0)
|
50
|
-
rubocop-ast (>= 0.4.0)
|
51
|
-
ruby-progressbar (1.11.0)
|
52
|
-
unicode-display_width (2.1.0)
|
53
|
-
|
54
|
-
PLATFORMS
|
55
|
-
ruby
|
56
|
-
|
57
|
-
DEPENDENCIES
|
58
|
-
dogstatsd-ruby
|
59
|
-
puma-plugin-telemetry!
|
60
|
-
rack
|
61
|
-
rake (~> 12.0)
|
62
|
-
rspec (~> 3.0)
|
63
|
-
rubocop (~> 1.5)
|
64
|
-
rubocop-performance (~> 1.9)
|
65
|
-
|
66
|
-
BUNDLED WITH
|
67
|
-
2.1.4
|
data/bin/console
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'bundler/setup'
|
5
|
-
require 'puma/plugin/telemetry'
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require 'irb'
|
15
|
-
IRB.start(__FILE__)
|