rorvswild 1.7.1 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rorvswild/agent.rb +38 -11
- data/lib/rorvswild/local/javascript/local.js +201 -36
- data/lib/rorvswild/local/local.html.erb +266 -68
- data/lib/rorvswild/local/middleware.rb +19 -4
- data/lib/rorvswild/local/queue.rb +45 -7
- data/lib/rorvswild/local/stylesheet/local.css +261 -59
- data/lib/rorvswild/local/stylesheet/vendor/prism.css +1 -1
- data/lib/rorvswild/local.rb +1 -1
- data/lib/rorvswild/plugin/action_controller.rb +1 -1
- data/lib/rorvswild/plugin/action_mailer.rb +1 -1
- data/lib/rorvswild/plugin/action_view.rb +1 -1
- data/lib/rorvswild/plugin/active_job.rb +1 -1
- data/lib/rorvswild/plugin/active_record.rb +1 -3
- data/lib/rorvswild/plugin/middleware.rb +7 -7
- data/lib/rorvswild/plugin/redis.rb +2 -6
- data/lib/rorvswild/queue.rb +4 -0
- data/lib/rorvswild/section.rb +62 -29
- data/lib/rorvswild/version.rb +1 -1
- data/lib/rorvswild.rb +14 -4
- metadata +3 -3
data/lib/rorvswild/section.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
module RorVsWild
|
4
4
|
class Section
|
5
|
-
attr_reader :
|
6
|
-
attr_accessor :kind, :file, :line, :calls, :
|
5
|
+
attr_reader :start_ms, :commands, :gc_start_ms
|
6
|
+
attr_accessor :kind, :file, :line, :calls, :children_ms, :total_ms, :gc_time_ms
|
7
7
|
|
8
8
|
def self.start(&block)
|
9
9
|
section = Section.new
|
@@ -15,8 +15,8 @@ module RorVsWild
|
|
15
15
|
def self.stop(&block)
|
16
16
|
return unless stack && section = stack.pop
|
17
17
|
block.call(section) if block_given?
|
18
|
-
section.
|
19
|
-
current.
|
18
|
+
section.stop
|
19
|
+
current.children_ms += section.total_ms if current
|
20
20
|
RorVsWild.agent.add_section(section)
|
21
21
|
end
|
22
22
|
|
@@ -28,17 +28,52 @@ module RorVsWild
|
|
28
28
|
(sections = stack) && sections.last
|
29
29
|
end
|
30
30
|
|
31
|
+
def self.start_gc_timing
|
32
|
+
section = Section.new
|
33
|
+
section.calls = GC.count
|
34
|
+
section.file, section.line = "ruby/gc.c", 42
|
35
|
+
section.add_command("GC.start")
|
36
|
+
section.kind = "gc"
|
37
|
+
section
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.stop_gc_timing(section)
|
41
|
+
section.total_ms = gc_total_ms - section.gc_start_ms
|
42
|
+
section.calls = GC.count - section.calls
|
43
|
+
section
|
44
|
+
end
|
45
|
+
|
46
|
+
if GC.respond_to?(:total_time)
|
47
|
+
def self.gc_total_ms
|
48
|
+
GC.total_time / 1_000_000.0 # nanosecond -> millisecond
|
49
|
+
end
|
50
|
+
else
|
51
|
+
def self.gc_total_ms
|
52
|
+
GC::Profiler.total_time * 1000 # second -> millisecond
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
31
56
|
def initialize
|
57
|
+
@start_ms = RorVsWild.clock_milliseconds
|
58
|
+
@end_ms = nil
|
59
|
+
@gc_start_ms = Section.gc_total_ms
|
60
|
+
@gc_end_ms = nil
|
61
|
+
@gc_time_ms = 0
|
32
62
|
@calls = 1
|
33
|
-
@
|
34
|
-
@
|
63
|
+
@total_ms = 0
|
64
|
+
@children_ms = 0
|
35
65
|
@kind = "code"
|
36
|
-
@started_at = RorVsWild.clock_milliseconds
|
37
66
|
location = RorVsWild.agent.locator.find_most_relevant_location(caller_locations)
|
38
67
|
@file = RorVsWild.agent.locator.relative_path(location.path)
|
39
68
|
@line = location.lineno
|
40
|
-
@
|
41
|
-
|
69
|
+
@commands = Set.new
|
70
|
+
end
|
71
|
+
|
72
|
+
def stop
|
73
|
+
@gc_end_ms = self.class.gc_total_ms
|
74
|
+
@gc_time_ms = @gc_end_ms - @gc_start_ms
|
75
|
+
@end_ms = RorVsWild.clock_milliseconds
|
76
|
+
@total_ms = @end_ms - @start_ms - gc_time_ms
|
42
77
|
end
|
43
78
|
|
44
79
|
def sibling?(section)
|
@@ -47,35 +82,33 @@ module RorVsWild
|
|
47
82
|
|
48
83
|
def merge(section)
|
49
84
|
self.calls += section.calls
|
50
|
-
self.
|
51
|
-
self.
|
52
|
-
|
53
|
-
|
54
|
-
self.command = self.command.dup if self.command.frozen?
|
55
|
-
self.command << "\n" + section.command
|
56
|
-
end
|
57
|
-
else
|
58
|
-
self.command = section.command
|
59
|
-
end
|
60
|
-
self.appendable_command = appendable_command && section.appendable_command
|
85
|
+
self.total_ms += section.total_ms
|
86
|
+
self.children_ms += section.children_ms
|
87
|
+
self.gc_time_ms += section.gc_time_ms
|
88
|
+
commands.merge(section.commands)
|
61
89
|
end
|
62
90
|
|
63
|
-
def
|
64
|
-
|
91
|
+
def self_ms
|
92
|
+
total_ms - children_ms
|
65
93
|
end
|
66
94
|
|
67
|
-
|
95
|
+
def as_json(options = nil)
|
96
|
+
{calls: calls, total_runtime: total_ms, children_runtime: children_ms, kind: kind, started_at: start_ms, file: file, line: line, command: command}
|
97
|
+
end
|
68
98
|
|
69
|
-
def
|
70
|
-
|
99
|
+
def to_json(options = {})
|
100
|
+
as_json.to_json(options)
|
71
101
|
end
|
72
102
|
|
73
|
-
def
|
74
|
-
|
103
|
+
def add_command(command)
|
104
|
+
commands << command
|
75
105
|
end
|
76
106
|
|
77
|
-
|
78
|
-
|
107
|
+
COMMAND_MAX_SIZE = 5_000
|
108
|
+
|
109
|
+
def command
|
110
|
+
string = @commands.to_a.join("\n")
|
111
|
+
string.size > COMMAND_MAX_SIZE ? string[0, COMMAND_MAX_SIZE] + " [TRUNCATED]" : string
|
79
112
|
end
|
80
113
|
end
|
81
114
|
end
|
data/lib/rorvswild/version.rb
CHANGED
data/lib/rorvswild.rb
CHANGED
@@ -26,8 +26,14 @@ module RorVsWild
|
|
26
26
|
@logger ||= initialize_logger
|
27
27
|
end
|
28
28
|
|
29
|
-
def self.measure(
|
30
|
-
|
29
|
+
def self.measure(method_or_code = nil, &block)
|
30
|
+
if block
|
31
|
+
measure_block(method_or_code, &block)
|
32
|
+
elsif method_or_code.is_a?(Method) || method_or_code.is_a?(UnboundMethod)
|
33
|
+
measure_method(method_or_code)
|
34
|
+
else
|
35
|
+
measure_code(method_or_code)
|
36
|
+
end
|
31
37
|
end
|
32
38
|
|
33
39
|
def self.measure_code(code)
|
@@ -38,6 +44,10 @@ module RorVsWild
|
|
38
44
|
agent ? agent.measure_block(name , &block) : block.call
|
39
45
|
end
|
40
46
|
|
47
|
+
def self.measure_method(method)
|
48
|
+
agent.measure_method(method) if agent
|
49
|
+
end
|
50
|
+
|
41
51
|
def self.catch_error(context = nil, &block)
|
42
52
|
agent ? agent.catch_error(context, &block) : block.call
|
43
53
|
end
|
@@ -67,13 +77,13 @@ module RorVsWild
|
|
67
77
|
end
|
68
78
|
|
69
79
|
def self.clock_milliseconds
|
70
|
-
Process.clock_gettime(Process::CLOCK_MONOTONIC, :
|
80
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)
|
71
81
|
end
|
72
82
|
|
73
83
|
def self.check
|
74
84
|
api_key = RorVsWild.agent.config[:api_key]
|
75
85
|
agent.client.instance_variable_set(:@http_unauthorized, false)
|
76
|
-
return puts "
|
86
|
+
return puts "Your API key is missing and has to be defined in config/rorvswild.yml." if !api_key || api_key.empty?
|
77
87
|
puts case response = agent.client.post("/jobs", jobs: [{sections: [], name: "RorVsWild.check", runtime: 0}])
|
78
88
|
when Net::HTTPOK then "Connection to RorVsWild works fine !"
|
79
89
|
when Net::HTTPUnauthorized then "Wrong API key"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rorvswild
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Bernard
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-10-17 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Performances and errors insights for rails developers.
|
15
15
|
email:
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
|
-
rubygems_version: 3.
|
89
|
+
rubygems_version: 3.5.9
|
90
90
|
signing_key:
|
91
91
|
specification_version: 4
|
92
92
|
summary: Ruby on Rails applications monitoring
|