rain_catcher 0.1.0
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 +7 -0
- data/.gitignore +15 -0
- data/.rspec +3 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +59 -0
- data/README.md +27 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rain_catcher.rb +8 -0
- data/lib/rain_catcher/railtie.rb +43 -0
- data/lib/rain_catcher/version.rb +5 -0
- data/rain_catcher.gemspec +31 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 21d83997891c531894ed0950c5d677d327f0cb3e8c38e594c691b6982e1a58b8
|
4
|
+
data.tar.gz: 404ae934f248a392261b66a8d8a9bea24542e34299a1007cfe1e0f1d3e8bd2e5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b8f8581204db2aa49eb41dee8d27e809e8194999173a2f26d5b77048232c2a226d24e24167ff0fbf001d82e0ee00bc14ef18e34ac09aa1a7a4c1b5a084205d77
|
7
|
+
data.tar.gz: 84bef156e860e96c468017f4bae93c6b35dff7c3a3b51027ad4b6738ad67233b3655bb4dad5f080d4a1a07f7311cdb82fc8a3ac0065c59f88fcf5c46da452751
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rain_catcher (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
concurrent-ruby (1.1.5)
|
11
|
+
diff-lcs (1.3)
|
12
|
+
i18n (1.6.0)
|
13
|
+
concurrent-ruby (~> 1.0)
|
14
|
+
jaro_winkler (1.5.2)
|
15
|
+
paint (2.1.0)
|
16
|
+
parallel (1.17.0)
|
17
|
+
parser (2.6.3.0)
|
18
|
+
ast (~> 2.4.0)
|
19
|
+
rainbow (3.0.0)
|
20
|
+
rake (10.5.0)
|
21
|
+
rspec (3.8.0)
|
22
|
+
rspec-core (~> 3.8.0)
|
23
|
+
rspec-expectations (~> 3.8.0)
|
24
|
+
rspec-mocks (~> 3.8.0)
|
25
|
+
rspec-core (3.8.0)
|
26
|
+
rspec-support (~> 3.8.0)
|
27
|
+
rspec-expectations (3.8.3)
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
+
rspec-support (~> 3.8.0)
|
30
|
+
rspec-mocks (3.8.0)
|
31
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
+
rspec-support (~> 3.8.0)
|
33
|
+
rspec-support (3.8.0)
|
34
|
+
rubocop (0.69.0)
|
35
|
+
jaro_winkler (~> 1.5.1)
|
36
|
+
parallel (~> 1.10)
|
37
|
+
parser (>= 2.6)
|
38
|
+
rainbow (>= 2.2.2, < 4.0)
|
39
|
+
ruby-progressbar (~> 1.7)
|
40
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
41
|
+
ruby-progressbar (1.10.0)
|
42
|
+
strong_versions (0.3.2)
|
43
|
+
i18n (>= 0.5.0)
|
44
|
+
paint (~> 2.0)
|
45
|
+
unicode-display_width (1.6.0)
|
46
|
+
|
47
|
+
PLATFORMS
|
48
|
+
ruby
|
49
|
+
|
50
|
+
DEPENDENCIES
|
51
|
+
bundler (~> 2.0)
|
52
|
+
rain_catcher!
|
53
|
+
rake (~> 10.0)
|
54
|
+
rspec (~> 3.0)
|
55
|
+
rubocop
|
56
|
+
strong_versions
|
57
|
+
|
58
|
+
BUNDLED WITH
|
59
|
+
2.0.1
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# RainCatcher
|
2
|
+
|
3
|
+
_RainCatcher_ utilises the [raindrops](https://bogomips.org/raindrops/) statistics tool to automatically log _Rack_ web server queue data for _Rails_ applications.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rain_catcher', '~> 0.1.0'
|
11
|
+
```
|
12
|
+
|
13
|
+
And rebuild your bundle:
|
14
|
+
```
|
15
|
+
bundle install
|
16
|
+
```
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
_RainCatcher_ automatically adds a hook into all web requests made to your application controller which will make a new log entry _not more frequently than_ a predetermined interval.
|
21
|
+
|
22
|
+
When each request is processed, if the configured interval has elapsed then a log entry will be made.
|
23
|
+
|
24
|
+
| Variable | Default Value | Meaning |
|
25
|
+
|-|-|-|
|
26
|
+
| `RAIN_CATCHER_LOG_INTERVAL` | 30 | Minimum number of seconds between each log entry |
|
27
|
+
| `RAIN_CATCHER_LOG_LEVEL` | INFO | Log level to use for log entries |
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rain_catcher"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/rain_catcher.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RainCatcher
|
4
|
+
class Railtie < Rails::Railtie
|
5
|
+
initializer :rain_catcher do
|
6
|
+
notifications.subscribe('process_action.action_controller') do |_args|
|
7
|
+
log_if_interval_elapsed
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def notifications
|
14
|
+
ActiveSupport::Notifications
|
15
|
+
end
|
16
|
+
|
17
|
+
def log_if_interval_elapsed
|
18
|
+
return unless elapsed?
|
19
|
+
|
20
|
+
Rails.logger.send(level, queue_data.to_json)
|
21
|
+
@last_logged = Time.now.utc
|
22
|
+
end
|
23
|
+
|
24
|
+
def queue_data
|
25
|
+
Raindrops::ListenStats.new(0, 0).to_h.merge(source: 'rain_catcher')
|
26
|
+
end
|
27
|
+
|
28
|
+
def elapsed?
|
29
|
+
return true if @last_logged.nil?
|
30
|
+
return true if (Time.now.utc - @last_logged).seconds >= interval
|
31
|
+
|
32
|
+
false
|
33
|
+
end
|
34
|
+
|
35
|
+
def interval
|
36
|
+
@interval ||= ENV.fetch('RAIN_CATCHER_LOG_INTERVAL', '30').to_i
|
37
|
+
end
|
38
|
+
|
39
|
+
def level
|
40
|
+
@level ||= ENV.fetch('RAIN_CATCHER_LOG_LEVEL', 'INFO').downcase.to_sym
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'rain_catcher/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'rain_catcher'
|
9
|
+
spec.version = RainCatcher::VERSION
|
10
|
+
spec.authors = ['Bob Farrell']
|
11
|
+
spec.email = ['robertanthonyfarrell@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = 'Automatically log Raindrops statistics'
|
14
|
+
spec.description = 'Rails application statistic logging with Raindrops'
|
15
|
+
spec.homepage = 'https://github.com/bobf/rain_catcher'
|
16
|
+
|
17
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
end
|
22
|
+
spec.bindir = 'exe'
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ['lib']
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
|
+
spec.add_development_dependency 'rubocop'
|
30
|
+
spec.add_development_dependency 'strong_versions'
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rain_catcher
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bob Farrell
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-05-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: strong_versions
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Rails application statistic logging with Raindrops
|
84
|
+
email:
|
85
|
+
- robertanthonyfarrell@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- Gemfile
|
93
|
+
- Gemfile.lock
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/console
|
97
|
+
- bin/setup
|
98
|
+
- lib/rain_catcher.rb
|
99
|
+
- lib/rain_catcher/railtie.rb
|
100
|
+
- lib/rain_catcher/version.rb
|
101
|
+
- rain_catcher.gemspec
|
102
|
+
homepage: https://github.com/bobf/rain_catcher
|
103
|
+
licenses: []
|
104
|
+
metadata: {}
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.7.6
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Automatically log Raindrops statistics
|
125
|
+
test_files: []
|