notable 0.6.0 → 0.6.1
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 +5 -0
- data/README.md +6 -2
- data/lib/notable/engine.rb +1 -1
- data/lib/notable/middleware.rb +13 -6
- data/lib/notable/throttle.rb +5 -0
- data/lib/notable/version.rb +1 -1
- data/lib/notable.rb +3 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5541640f476e0e97318e6767a54afaa5cdeb0d35891372f87eef3d528e5ceaaa
|
|
4
|
+
data.tar.gz: 8d16fd5688ad556b83c72ab9787ccac3fb2c0ba55468a3d6c829a4166110e64a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba086c17aa9de949c21349d6c754addb8de84f31635b3a57f7a52bce63aee66cce22476926c347a231456f4cd837765c83543636624f61237e197f5896ec227c
|
|
7
|
+
data.tar.gz: 135bebfd4c0acfa206d6acd39099040db35a90c98b5b13fe01e056253e953e685fe6ad00836a98e8443d412324d7e517ead6332ed2332f6c891b2a7dd146bb9c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# Notable
|
|
2
2
|
|
|
3
|
-
:star2: :star2: :star2:
|
|
4
|
-
|
|
5
3
|
Notable tracks notable requests and background jobs and stores them in your database. What makes a request or job notable? There are a number of default situations, but ultimately you decide what interests you.
|
|
6
4
|
|
|
7
5
|
By default, Notable tracks:
|
|
@@ -108,6 +106,12 @@ Anonymize IP addresses
|
|
|
108
106
|
Notable.mask_ips = true
|
|
109
107
|
```
|
|
110
108
|
|
|
109
|
+
Scrub invalid UTF-8 from data
|
|
110
|
+
|
|
111
|
+
```ruby
|
|
112
|
+
Notable.scrub_invalid_utf8 = true
|
|
113
|
+
```
|
|
114
|
+
|
|
111
115
|
### Jobs
|
|
112
116
|
|
|
113
117
|
Set slow threshold
|
data/lib/notable/engine.rb
CHANGED
|
@@ -6,7 +6,7 @@ module Notable
|
|
|
6
6
|
if Notable.requests_enabled?
|
|
7
7
|
# insert in same place as request_store
|
|
8
8
|
app.config.middleware.insert_after ActionDispatch::RequestId, Notable::Middleware
|
|
9
|
-
# TODO switch to register_interceptor in 0.
|
|
9
|
+
# TODO switch to register_interceptor in 0.7.0
|
|
10
10
|
ActionDispatch::DebugExceptions.prepend Notable::DebugExceptions
|
|
11
11
|
end
|
|
12
12
|
end
|
data/lib/notable/middleware.rb
CHANGED
|
@@ -10,8 +10,7 @@ module Notable
|
|
|
10
10
|
request_time = Notable.monotonic_time - start_time
|
|
11
11
|
|
|
12
12
|
Safely.safely do
|
|
13
|
-
if env["action_dispatch.exception"]
|
|
14
|
-
e = env["action_dispatch.exception"]
|
|
13
|
+
if (e = env["action_dispatch.exception"]) && (!defined?(ActionController::TooManyRequests) || !e.is_a?(ActionController::TooManyRequests))
|
|
15
14
|
message =
|
|
16
15
|
case status.to_i
|
|
17
16
|
when 404
|
|
@@ -37,11 +36,19 @@ module Notable
|
|
|
37
36
|
url = request.original_url
|
|
38
37
|
|
|
39
38
|
controller = env["action_controller.instance"]
|
|
40
|
-
action = controller && "#{controller.
|
|
41
|
-
params = controller && controller.request.filtered_parameters.except("controller", "action")
|
|
39
|
+
action = controller && "#{controller.controller_path}##{controller.action_name}"
|
|
40
|
+
params = controller && (controller.request.filtered_parameters.except("controller", "action") rescue nil)
|
|
42
41
|
|
|
43
42
|
user = Notable.user_method.call(env)
|
|
44
43
|
|
|
44
|
+
user_agent = request.user_agent
|
|
45
|
+
referrer = request.referer
|
|
46
|
+
|
|
47
|
+
if Notable.scrub_invalid_utf8
|
|
48
|
+
user_agent = user_agent.scrub
|
|
49
|
+
referrer = referrer.scrub
|
|
50
|
+
end
|
|
51
|
+
|
|
45
52
|
notes.each do |note|
|
|
46
53
|
ip = request.remote_ip
|
|
47
54
|
if ip && Notable.mask_ips
|
|
@@ -57,9 +64,9 @@ module Notable
|
|
|
57
64
|
params: params,
|
|
58
65
|
request_id: request.uuid,
|
|
59
66
|
ip: ip,
|
|
60
|
-
user_agent:
|
|
67
|
+
user_agent: user_agent,
|
|
61
68
|
url: url,
|
|
62
|
-
referrer:
|
|
69
|
+
referrer: referrer,
|
|
63
70
|
request_time: request_time
|
|
64
71
|
}
|
|
65
72
|
Notable.track_request_method.call(data, env)
|
data/lib/notable/throttle.rb
CHANGED
|
@@ -5,3 +5,8 @@ ActiveSupport::Notifications.subscribe "rack.attack" do |_name, _start, _finish,
|
|
|
5
5
|
Notable.track "Throttle", request.env["rack.attack.matched"]
|
|
6
6
|
end
|
|
7
7
|
end
|
|
8
|
+
|
|
9
|
+
# TODO uncomment in 0.7.0
|
|
10
|
+
# ActiveSupport::Notifications.subscribe "rate_limit.action_controller" do |_|
|
|
11
|
+
# Notable.track "Throttle", "throttle note"
|
|
12
|
+
# end
|
data/lib/notable/version.rb
CHANGED
data/lib/notable.rb
CHANGED
|
@@ -22,6 +22,7 @@ module Notable
|
|
|
22
22
|
attr_accessor :user_method
|
|
23
23
|
attr_accessor :slow_request_threshold
|
|
24
24
|
attr_accessor :mask_ips
|
|
25
|
+
attr_accessor :scrub_invalid_utf8
|
|
25
26
|
|
|
26
27
|
# jobs
|
|
27
28
|
attr_accessor :track_job_method
|
|
@@ -31,6 +32,8 @@ module Notable
|
|
|
31
32
|
self.requests_enabled = true
|
|
32
33
|
self.jobs_enabled = true
|
|
33
34
|
self.mask_ips = false
|
|
35
|
+
# TODO default to true in 0.7.0
|
|
36
|
+
self.scrub_invalid_utf8 = false
|
|
34
37
|
|
|
35
38
|
def self.requests_enabled?
|
|
36
39
|
enabled && requests_enabled
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: notable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Kane
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activesupport
|
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
79
79
|
- !ruby/object:Gem::Version
|
|
80
80
|
version: '0'
|
|
81
81
|
requirements: []
|
|
82
|
-
rubygems_version:
|
|
82
|
+
rubygems_version: 4.0.3
|
|
83
83
|
specification_version: 4
|
|
84
84
|
summary: Track notable requests and background jobs
|
|
85
85
|
test_files: []
|