puma-stats 1.0.2 → 1.0.3
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/CHANGELOG.md +4 -0
- data/README.md +3 -6
- data/lib/puma/plugin/stats.rb +0 -2
- data/lib/puma/stats/app.rb +7 -8
- data/lib/puma/stats/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef7fa50d902e1e9900d76b38a9e919edadf35e0d
|
4
|
+
data.tar.gz: 92e71ac20a28570fb41c735a531f5382684c53c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15765d516a6ba83f8deb42aad7bcd4aa04ec750be73523073f116866c886bb4d58939dc72fa819897f6cbb48adc308a706d47d4ac5a9029e4e63907fba2dd262
|
7
|
+
data.tar.gz: 22d21639ab1bafe316b34bbff6afaa86d41c25775cdc6bd7b5f2922f67bf15bb1c2d3ea53f4285daaae8337ab553dd62961d7e57ee6e861d3ae83b42468bba12
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -27,17 +27,14 @@ Add following lines to your puma `config.rb` (see
|
|
27
27
|
# config/puma.rb
|
28
28
|
|
29
29
|
plugin 'stats'
|
30
|
-
|
31
|
-
|
32
|
-
#
|
33
|
-
# stats_url 'tcp://0.0.0.0:12345'
|
34
|
-
# stats_token 'knockknock'
|
30
|
+
stats_url 'tcp://0.0.0.0:12345'
|
31
|
+
stats_token 'knockknock'
|
35
32
|
```
|
36
33
|
|
37
34
|
## Credits
|
38
35
|
|
39
36
|
The gem is inspired by the following projects:
|
40
|
-
* https://github.com/
|
37
|
+
* https://github.com/harmjanblok/puma-metrics
|
41
38
|
|
42
39
|
## License
|
43
40
|
|
data/lib/puma/plugin/stats.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require 'puma/stats/dsl'
|
4
4
|
|
5
5
|
Puma::Plugin.create do
|
6
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
7
6
|
def start(launcher)
|
8
7
|
str = launcher.options[:stats_url] || 'tcp://0.0.0.0:51209'
|
9
8
|
|
@@ -41,5 +40,4 @@ Puma::Plugin.create do
|
|
41
40
|
|
42
41
|
stats.run
|
43
42
|
end
|
44
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
45
43
|
end
|
data/lib/puma/stats/app.rb
CHANGED
@@ -11,19 +11,17 @@ module Puma
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def call(env)
|
14
|
-
unless authenticate(env)
|
15
|
-
return rack_response(403, "Invalid stats auth token", 'text/plain')
|
16
|
-
end
|
14
|
+
return rack_response(403, 'Invalid stats auth token', 'text/plain') unless authenticate(env)
|
17
15
|
|
18
16
|
case env['PATH_INFO']
|
19
|
-
when
|
17
|
+
when %r{/puma-stats-gc$}
|
20
18
|
rack_response(200, GC.stat.to_json)
|
21
19
|
|
22
|
-
when
|
20
|
+
when %r{/puma-stats$}
|
23
21
|
rack_response(200, @launcher.stats)
|
24
22
|
|
25
23
|
else
|
26
|
-
rack_response 404,
|
24
|
+
rack_response 404, 'Unsupported request', 'text/plain'
|
27
25
|
end
|
28
26
|
end
|
29
27
|
|
@@ -31,12 +29,13 @@ module Puma
|
|
31
29
|
|
32
30
|
def authenticate(env)
|
33
31
|
return true unless @auth_token
|
32
|
+
|
34
33
|
env['QUERY_STRING'].to_s.split(/&;/).include?("token=#{@auth_token}")
|
35
34
|
end
|
36
35
|
|
37
|
-
def rack_response(status, body, content_type='application/json')
|
36
|
+
def rack_response(status, body, content_type = 'application/json')
|
38
37
|
headers = {
|
39
|
-
'Content-Type'
|
38
|
+
'Content-Type' => content_type,
|
40
39
|
'Content-Length' => body.bytesize.to_s
|
41
40
|
}
|
42
41
|
[status, headers, [body]]
|
data/lib/puma/stats/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puma-stats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Kishel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puma
|