notable 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/notable/middleware.rb +4 -4
- data/lib/notable/version.rb +1 -1
- data/lib/notable.rb +12 -4
- 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: 714094d0059bb07c9e66ab382626795bc81b1e8cdd695f7354198531bab9caa9
|
4
|
+
data.tar.gz: bc36e2654ebd17188b2fb913d3f745ebf40487a57f1e0e82b3ca6a041d4d9975
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1590cf5d58fcb9d9bf8021081392b089390218ae3fc525a44f4404dad41302c12c54117aeee658386855321458e17360f12b5ef98bb263e401ee106a95820341
|
7
|
+
data.tar.gz: d128c411ed50df17b835d6dcddad2d9dcf3bc0c7094756586709316f604ba0a63cbb5ca00d79f192285895d854f9f8a3c2d4ec3adcf14699cc016b097fa44923
|
data/CHANGELOG.md
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
@@ -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.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
|
-
rubygems_version: 3.3.
|
85
|
+
rubygems_version: 3.3.7
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: Track notable requests and background jobs
|