notable 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/LICENSE.txt +1 -1
- data/lib/notable/middleware.rb +4 -4
- data/lib/notable/version.rb +1 -1
- data/lib/notable.rb +18 -10
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6901159f15d1920eaf07ff40c239d4b05d75bb469c55ddebc67874703e362efe
|
4
|
+
data.tar.gz: 5092cf2e632b615faaae6a1027104597ab4a434102374f9fc7a0eff7c5246b46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc4b419c11fc0dae0cac44c8ba581cff4df203cb4be3b462876e46b315139b3f2e71737ef69e2c28c07ed05ce3840aab6602ada5739bb51a0e5b2d5dc5abfbd4
|
7
|
+
data.tar.gz: c0ce85fa70b1930db449a3570f29c2e41adf13db86c5a2ade506978294de6daf82e4231ea7ce1fbe226b82cbcac63c87db4aaeb9748b114796b34610650913f5
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/lib/notable/middleware.rb
CHANGED
@@ -5,9 +5,9 @@ module Notable
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def call(env)
|
8
|
-
start_time =
|
8
|
+
start_time = Notable.monotonic_time
|
9
9
|
status, headers, body = @app.call(env)
|
10
|
-
request_time =
|
10
|
+
request_time = Notable.monotonic_time - start_time
|
11
11
|
|
12
12
|
Safely.safely do
|
13
13
|
if env["action_dispatch.exception"]
|
@@ -22,11 +22,11 @@ module Notable
|
|
22
22
|
"Error"
|
23
23
|
end
|
24
24
|
Notable.track message, "#{e.class.name}: #{e.message}"
|
25
|
-
elsif (!status
|
25
|
+
elsif (!status || status.to_i >= 400) && !Notable.notes.any?
|
26
26
|
Notable.track Rack::Utils::HTTP_STATUS_CODES[status.to_i]
|
27
27
|
end
|
28
28
|
|
29
|
-
if request_time > Notable.slow_request_threshold
|
29
|
+
if request_time > Notable.slow_request_threshold && status.to_i != 503
|
30
30
|
Notable.track "Slow Request"
|
31
31
|
end
|
32
32
|
|
data/lib/notable/version.rb
CHANGED
data/lib/notable.rb
CHANGED
@@ -3,13 +3,13 @@ require "active_support"
|
|
3
3
|
require "safely/core"
|
4
4
|
|
5
5
|
# modules
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
require_relative "notable/debug_exceptions"
|
7
|
+
require_relative "notable/middleware"
|
8
|
+
require_relative "notable/throttle"
|
9
|
+
require_relative "notable/unpermitted_parameters"
|
10
|
+
require_relative "notable/version"
|
11
11
|
|
12
|
-
|
12
|
+
require_relative "notable/engine" if defined?(Rails)
|
13
13
|
|
14
14
|
module Notable
|
15
15
|
class << self
|
@@ -69,9 +69,8 @@ module Notable
|
|
69
69
|
slow_job_threshold ||= Notable.slow_job_threshold
|
70
70
|
exception = nil
|
71
71
|
notes = nil
|
72
|
-
|
73
|
-
|
74
|
-
queued_time = created_at ? start_time - created_at : nil
|
72
|
+
started_at = Time.now # wall time
|
73
|
+
start_time = monotonic_time
|
75
74
|
begin
|
76
75
|
yield
|
77
76
|
rescue Exception => e
|
@@ -81,11 +80,16 @@ module Notable
|
|
81
80
|
notes = Notable.notes
|
82
81
|
Notable.clear_notes
|
83
82
|
end
|
84
|
-
runtime =
|
83
|
+
runtime = monotonic_time - start_time
|
85
84
|
|
86
85
|
Safely.safely do
|
87
86
|
notes << {note_type: "Slow Job"} if runtime > slow_job_threshold
|
88
87
|
|
88
|
+
if notes.any?
|
89
|
+
created_at = Time.parse(created_at) if created_at.is_a?(String)
|
90
|
+
queued_time = created_at ? [started_at - created_at, 0].max : nil
|
91
|
+
end
|
92
|
+
|
89
93
|
notes.each do |note|
|
90
94
|
data = {
|
91
95
|
note_type: note[:note_type],
|
@@ -114,6 +118,10 @@ module Notable
|
|
114
118
|
addr.mask(48).to_s
|
115
119
|
end
|
116
120
|
end
|
121
|
+
|
122
|
+
def self.monotonic_time
|
123
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
124
|
+
end
|
117
125
|
end
|
118
126
|
|
119
127
|
ActiveSupport.on_load(:action_controller) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.1'
|
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: '6.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: safely_block
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: '0.4'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: '0.4'
|
41
41
|
description:
|
42
42
|
email: andrew@ankane.org
|
43
43
|
executables: []
|
@@ -75,14 +75,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
75
|
requirements:
|
76
76
|
- - ">="
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
version: '
|
78
|
+
version: '3'
|
79
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
|
-
rubygems_version: 3.
|
85
|
+
rubygems_version: 3.4.10
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: Track notable requests and background jobs
|