rorvswild 1.11.0 → 1.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b29f5881ffc0b495ede8b88ca53f68161a5bbfa09ca4005c0384a18f17a77ce9
4
- data.tar.gz: 8cf948c1c9ea720aeb35068160e61a506085194c3ad2f5caa5b43f6c6c5ee5a2
3
+ metadata.gz: 78dcaca37ba08f20d8b6fa091902f46973d48db05feabce1ab4600bd4afb48c3
4
+ data.tar.gz: 626507452a31fe1e63fab2826d239c4d13f03c36e8bda1690deb1ba766733bc6
5
5
  SHA512:
6
- metadata.gz: 90e4b903eec8db8e89d3c6fdb77397bb75e7bb09212d7cc86fea9a865b1d5d13ab7ea9e9d9d7d199fda10ad20d3b5fb12749eb41841329de0db0b6893e05e6db
7
- data.tar.gz: 1745b14bce30d4dccc1584e35c301f55b481156f8919e5030fee11c52e879ff6b7e77b2128b286d1566f0b407666799e6b4c6551b30e457a66b3ac213e1ce0bd
6
+ metadata.gz: 89a838d0e59c7a552ef0b961efe32420e9f271dbff74ca9427be809dc07b8a5b6158be53c10aac5bb3c69cfb6d1682e034b5b3d5f01898814e68f2443b3ffa6e
7
+ data.tar.gz: 35e531b0cfe704c0641ac075713893a46a55aefd453cc6fea5a34f2f3b814639096834bb8e9a9adfb11d2041693282da525a2e2b47c3d8c830e9003050e43bdd
@@ -113,12 +113,10 @@ module RorVsWild
113
113
 
114
114
  def start_execution(execution)
115
115
  Thread.current[:rorvswild_execution] ||= execution
116
- RorVsWild::Section.start
117
116
  end
118
117
 
119
118
  def stop_execution
120
119
  return unless execution = current_execution
121
- RorVsWild::Section.stop
122
120
  execution.stop
123
121
  case execution
124
122
  when Execution::Job then queue_job
@@ -2,21 +2,21 @@
2
2
 
3
3
  module RorVsWild
4
4
  class Execution
5
- attr_reader :parameters, :sections, :section_stack, :error_context, :runtime
5
+ attr_reader :parameters, :sections, :section_stack, :error_context, :runtime, :root_section, :queue_section
6
6
 
7
7
  attr_accessor :error, :name
8
8
 
9
9
  def initialize(name, parameters)
10
+ @root_section = Section::Root.new
11
+
10
12
  @name = name
11
13
  @parameters = parameters
12
14
  @runtime = nil
13
15
  @error = nil
14
16
  @error_context = nil
15
17
 
16
- @started_at = RorVsWild.clock_milliseconds
17
- @gc_section = Section.start_gc_timing
18
18
  @environment = Host.to_h
19
- @section_stack = []
19
+ @section_stack = [@root_section]
20
20
  @sections = []
21
21
  end
22
22
 
@@ -30,20 +30,18 @@ module RorVsWild
30
30
 
31
31
  def add_queue_time(queue_time_ms)
32
32
  return unless queue_time_ms
33
- @started_at -= queue_time_ms
34
- section = Section.new
35
- section.total_ms = queue_time_ms
36
- section.gc_time_ms = 0
37
- section.file = "queue"
38
- section.line = 0
39
- section.kind = "queue"
40
- add_section(section)
33
+ @queue_section = Section::Queue.new(queue_time_ms)
34
+ add_section(@queue_section)
35
+ @queue_section
41
36
  end
42
37
 
43
38
  def stop
44
- Section.stop_gc_timing(@gc_section)
45
- @sections << @gc_section if @gc_section.calls > 0 && @gc_section.total_ms > 0
46
- @runtime = RorVsWild.clock_milliseconds - @started_at
39
+ Section.stop # root section
40
+ if @root_section.gc_time_ms > 0
41
+ add_section(Section::GarbageCollection.new(@root_section.gc_time_ms, @root_section.gc_calls))
42
+ end
43
+ @runtime = @root_section.total_ms + @root_section.gc_time_ms
44
+ @runtime += @queue_section.total_ms if @queue_section
47
45
  end
48
46
 
49
47
  def as_json(options = nil)
@@ -66,25 +64,6 @@ module RorVsWild
66
64
 
67
65
  private
68
66
 
69
- def start_gc_timing
70
- section = Section.new
71
- section.calls = GC.count
72
- section.file, section.line = "ruby/gc.c", 0
73
- section.add_command("GC.start")
74
- section.kind = "gc"
75
- section
76
- end
77
-
78
- if GC.respond_to?(:total_time)
79
- def gc_total_ms
80
- GC.total_time / 1_000_000.0 # nanosecond -> millisecond
81
- end
82
- else
83
- def gc_total_ms
84
- GC::Profiler.total_time * 1000 # second -> millisecond
85
- end
86
- end
87
-
88
67
  class Job < Execution
89
68
  def add_exception(exception)
90
69
  super(exception)
@@ -27,41 +27,54 @@ development:
27
27
  # editor_url: <%= ENV.fetch("RORVSWILD_EDITOR_URL", "vscode://file${path}:${line}") %>
28
28
  # for VSCode: "vscode://file${path}:${line}"
29
29
  # for Sublime: "subl://${path}:${line}"
30
-
31
30
 
32
31
  production:
33
- api_key: #{api_key}
34
- # ignore_requests: # Do not monitor the following actions
35
- # - SecretController#index
36
- # ignore_jobs: # Do not monitor the following jobs
37
- # - SecretJob
38
- # ignore_exceptions: # Do not record the following exceptions
39
- # - ActionController::RoutingError # By default to ignore 404
40
- # ignore_plugins:
41
- # - ActionController
42
- # - ActionMailer
43
- # - ActionView
44
- # - ActiveJob
45
- # - ActiveRecord
46
- # - DelayedJob
47
- # - Elasticsearch
48
- # - Mongo
49
- # - NetHttp
50
- # - Redis
51
- # - Resque
52
- # - Sidekiq
53
- #
32
+ api_key: <%= ENV["RORVSWILD_API_KEY"] || "#{api_key}" %>
33
+
34
+ # Do not monitor the following actions.
35
+ ignore_requests:
36
+ - SecretController#index
37
+
38
+ # Do not monitor the following jobs.
39
+ ignore_jobs:
40
+ - SecretJob
41
+
42
+ # Do not monitor the following exceptions.
43
+ ignore_exceptions:
44
+ # Noisy exceptions such as ActionNotFound, UnknownHttpMethod, etc are ignored by default.
45
+ - <%= ActionDispatch::ExceptionWrapper.rescue_responses.keys.join("\\n - ") %>
46
+ - AnotherNoisyError
47
+
48
+ # In case you want less details.
49
+ ignore_plugins:
50
+ # - ActionController
51
+ # - ActionMailer
52
+ # - ActionView
53
+ # - ActiveJob
54
+ # - ActiveRecord
55
+ # - DelayedJob
56
+ # - Elasticsearch
57
+ # - Faktory
58
+ # - Mongo
59
+ # - NetHttp
60
+ # - Rack
61
+ # - RailsCache
62
+ # - RailsError
63
+ # - Redis
64
+ # - Resque
65
+ # - Sidekiq
66
+
54
67
  # logger: log/rorvswild.log # By default it uses Rails.logger or Logger.new(STDOUT)
55
- #
56
- # # Deployment tracking is working without any actions from your part if the Rails app
57
- # # is inside a Git repository, is deployed via Capistrano.
58
- # # In the other cases, you can provide the following details.
68
+
69
+ # Deployment tracking is working without any actions from your part if the Rails app
70
+ # is inside a Git repository, or deployed with Capistrano, Kamal, Heroku or Scalingo.
71
+ # In the other cases, you can provide the following details.
59
72
  # deployment:
60
73
  # revision: <%= "Anything that will return the deployment version" %> # Mandatory
61
74
  # description: <%= "Eventually if you have a description such as a Git message" %>
62
75
  # author: <%= "Author's name of the deployment" %>
63
76
  # email: <%= "emailOf@theAuthor.example" %>
64
- #
77
+
65
78
  # Sampling allows to send a fraction of jobs and requests.
66
79
  # If your app is sending hundred of millions of requests per month,
67
80
  # you will probably get the same precision if you send only a fraction of it.
@@ -50,6 +50,9 @@ module RorVsWild
50
50
  SQL_ONE_LINE_COMMENT_REGEX =/--.*$/
51
51
  SQL_MULTI_LINE_COMMENT_REGEX = /\/\*.*?\*\//m
52
52
 
53
+ # Catch Regexp::TimeoutError without breaking before Ruby 3.2
54
+ REGEXP_TIMEOUT_ERROR = defined?(Regexp::TimeoutError) ? Regexp::TimeoutError : RegexpError
55
+
53
56
  def normalize_sql_query(sql)
54
57
  sql = sql.to_s.gsub(SQL_STRING_REGEX, "?")
55
58
  sql.gsub!(SQL_PARAMETER_REGEX, "?")
@@ -59,6 +62,8 @@ module RorVsWild
59
62
  sql.gsub!(SQL_MULTI_LINE_COMMENT_REGEX, "")
60
63
  sql.strip!
61
64
  sql
65
+ rescue REGEXP_TIMEOUT_ERROR
66
+ nil
62
67
  end
63
68
  end
64
69
  end
@@ -58,12 +58,11 @@ module RorVsWild
58
58
  execution = RorVsWild::Execution::Request.new(env["REQUEST_URI"])
59
59
  execution.add_queue_time(calculate_queue_time(env))
60
60
  RorVsWild.agent.start_execution(execution)
61
- section = RorVsWild::Section.start
61
+ section = execution.root_section
62
62
  section.file, section.line = method(:call).super_method.source_location
63
63
  section.commands << "Rails::Engine#call"
64
64
  super
65
65
  ensure
66
- RorVsWild::Section.stop
67
66
  RorVsWild.agent.stop_execution
68
67
  end
69
68
 
@@ -28,21 +28,6 @@ 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", 0
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
31
  if GC.respond_to?(:total_time)
47
32
  def self.gc_total_ms
48
33
  GC.total_time / 1_000_000.0 # nanosecond -> millisecond
@@ -111,5 +96,46 @@ module RorVsWild
111
96
  string = @commands.to_a.join("\n")
112
97
  string.size > COMMAND_MAX_SIZE ? string[0, COMMAND_MAX_SIZE] + " [TRUNCATED]" : string
113
98
  end
99
+
100
+ class Root < Section
101
+ attr_reader :gc_calls
102
+
103
+ def initialize
104
+ super
105
+ @gc_count = GC.count
106
+ end
107
+
108
+ def stop
109
+ super
110
+ @gc_calls = GC.count - @gc_count
111
+ end
112
+ end
113
+
114
+ class GarbageCollection < Section
115
+ def initialize(total_ms, calls)
116
+ @total_ms = total_ms
117
+ @calls = calls > 0 ? calls : 1
118
+ @kind = "gc"
119
+ @file, @line = "ruby/gc.c", 0
120
+ @commands = Set.new
121
+ @children_ms = 0
122
+ @async_ms = 0
123
+ add_command("GC.start")
124
+ end
125
+ end
126
+
127
+ class Queue < Section
128
+ def initialize(total_ms)
129
+ @total_ms = total_ms
130
+ @gc_time_ms = 0
131
+ @file = "queue"
132
+ @line = 0
133
+ @kind = "queue"
134
+ @calls = 1
135
+ @children_ms = 0
136
+ @gc_time_ms = 0
137
+ @async_ms = 0
138
+ end
139
+ end
114
140
  end
115
141
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RorVsWild
4
- VERSION = "1.11.0"
4
+ VERSION = "1.11.1"
5
5
  end
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.11.0
4
+ version: 1.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Bernard