builder_apm 0.5.3 → 0.5.6

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: 1d4bce6745bf405a2373b99d571aed8e87ece7c99fd6041bfc2ce8965d3583e4
4
- data.tar.gz: '0812e1ac70543838da93f3c586a1eae82801387cf9fb1735f0636b919a92690b'
3
+ metadata.gz: d92ead706d6d43ec760d3aa3013f130be9a6cf096282b194324c3563cd945a65
4
+ data.tar.gz: 05ba3ed9fbe3bf2dc505511087627b81ed5d4b6d3f441f103d84ef76ae8305f2
5
5
  SHA512:
6
- metadata.gz: ac4ea9b284511b3e4e0e6639099b178d47b30839bbdfa3b686d8a09fd551338540a76940013665ec53c0b3e7f694c06f64cf48b78696085a903e1527cdd6cd9b
7
- data.tar.gz: '0608598b9404aea84e2d6ed6fa63bce8cf4d4b1f8454b4c77ceb69765947af7b2064742b2f95bf37179f291da3e69ab88d57bd86c11dc712fbb7aea349258d45'
6
+ metadata.gz: d27c722cc27f63d497157fff8cdec589136b68f8ab18bbbd8fa0e7d9e13e4e9dc96b39656c6e717ab87158b700ada76beda0b192e6c2f5dfa224654c833cd4c3
7
+ data.tar.gz: bee94e64a77c9a7fb9a2d7ea08d8d711eac7d9d73fb08f8a66a798e8669ce8594d753292468e22139716b0718e53d2ded6b13831fff203efe75fa2b0e20135bd
@@ -346,6 +346,7 @@
346
346
 
347
347
  // Check if results are more than 50
348
348
  if (item.record_count > 50) {
349
+ resultsSpan.append('🚨');
349
350
  resultsSpan.addClass('highlight-results').attr('title', "This is a large number of results. Review if this can be paginated or limited.");
350
351
  }
351
352
 
@@ -20,6 +20,8 @@ module BuilderApm
20
20
  uuid = event.payload[:headers].env['action_dispatch.request_id']
21
21
  Thread.current[:request_id] = uuid
22
22
  Thread.current[:stack] = [setup_controller_stack_data(event)]
23
+ Thread.current[:method_tracing] = 0
24
+ Thread.current[:db_tracing] = 0
23
25
  end
24
26
 
25
27
  def process_action(event)
@@ -28,74 +28,51 @@ module BuilderApm
28
28
  end
29
29
 
30
30
  def valid_trace_point?(tp)
31
- Thread.current[:request_id] && not_controller_endpoint(tp) && valid_gem_path(tp)
32
- end
33
-
34
- def not_controller_endpoint(tp)
35
- start_controller = Thread.current[:stack]&.first || nil
36
-
37
- return false unless start_controller
38
-
39
- "#{tp.defined_class}##{tp.method_id}" != start_controller[:method]
40
- end
41
-
42
- def valid_gem_path(tp)
43
- return true if tp.path.start_with?(@root_path)
44
- return false if tp.path.start_with?(@this_gem_path)
45
- return false if gems_to_track.empty?
46
-
47
- gems_to_track.any? { |gem| tp.path.include?(File::SEPARATOR + gem) }
31
+ return false unless Thread.current[:request_id]
32
+ return false unless tp.path.start_with?(@root_path)
33
+
34
+ start_controller = Thread.current[:stack]&.first
35
+ start_controller && "#{tp.defined_class}##{tp.method_id}" == start_controller[:method]
36
+
37
+ # gems_to_track = BuilderApm.configuration.gems_to_track
38
+ # gems_to_track.any? { |gem| tp.path.include?(File::SEPARATOR + gem) }
48
39
  end
49
40
 
50
41
  def process_trace_point(tp)
51
42
  if tp.event == :call || tp.event == :b_call || tp.event == :c_call
52
- process_call_event(tp)
43
+ method_id = "#{tp.defined_class}##{tp.method_id}"
44
+ (@call_times[method_id]||= []) << Process.clock_gettime(Process::CLOCK_MONOTONIC)
45
+ caller_info = caller_locations(4,1).first
46
+ calling_file_path = caller_info.absolute_path
47
+ calling_line_number = caller_info.lineno
48
+
49
+ method_call = {
50
+ method: method_id,
51
+ method_line: "#{tp.path.gsub(@root_path, '')}:#{tp.lineno}",
52
+ triggering_line: "#{calling_file_path.gsub(@root_path, '')}:#{calling_line_number}",
53
+ children: [],
54
+ start_time: Time.now.to_f * 1000,
55
+ sql_events: []
56
+ }
57
+
58
+ (Thread.current[:stack] ||= []).push(method_call)
53
59
  else
54
- process_return_event(tp)
55
- end
56
- end
57
-
58
- private
59
-
60
- def gems_to_track
61
- @gems_to_track = BuilderApm.configuration.gems_to_track
62
- end
63
-
64
- def process_call_event(tp)
65
- method_id = "#{tp.defined_class}##{tp.method_id}"
66
- (@call_times[method_id]||= []) << Process.clock_gettime(Process::CLOCK_MONOTONIC)
67
- caller_info = caller_locations(4,1).first
68
- calling_file_path = caller_info.absolute_path
69
- calling_line_number = caller_info.lineno
70
-
71
- method_call = {
72
- method: method_id,
73
- method_line: "#{tp.path.gsub(@root_path, '')}:#{tp.lineno}",
74
- triggering_line: "#{calling_file_path.gsub(@root_path, '')}:#{calling_line_number}",
75
- children: [],
76
- start_time: Time.now.to_f * 1000,
77
- sql_events: []
78
- }
79
-
80
- (Thread.current[:stack] ||= []).push(method_call)
81
- end
82
-
83
- def process_return_event(tp)
84
- method_id = "#{tp.defined_class}##{tp.method_id}"
85
-
86
- if @call_times.key?(method_id)
87
- elapsed_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) - @call_times[method_id].pop
88
- elapsed_time_in_ms = (elapsed_time * 1000).round(3)
89
- @call_times.delete(method_id)
90
-
91
- method_call = (Thread.current[:stack] ||= []).pop
92
- method_call[:end_time] = Time.now.to_f * 1000
93
- method_call[:duration] = elapsed_time_in_ms
94
-
95
- if Thread.current[:stack]&.any?
96
- Thread.current[:stack].last[:children].push(method_call)
97
- else
98
- Thread.current[:stack].push(method_call)
60
+ method_id = "#{tp.defined_class}##{tp.method_id}"
61
+
62
+ if @call_times.key?(method_id)
63
+ elapsed_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) - @call_times[method_id].pop
64
+ elapsed_time_in_ms = (elapsed_time * 1000).round(3)
65
+ @call_times.delete(method_id)
66
+
67
+ method_call = (Thread.current[:stack] ||= []).pop
68
+ method_call[:end_time] = Time.now.to_f * 1000
69
+ method_call[:duration] = elapsed_time_in_ms
70
+
71
+ if Thread.current[:stack]&.any?
72
+ Thread.current[:stack].last[:children].push(method_call)
73
+ else
74
+ Thread.current[:stack].push(method_call)
75
+ end
99
76
  end
100
77
  end
101
78
  end
@@ -7,6 +7,7 @@ module BuilderApm
7
7
  end
8
8
 
9
9
  def call(env)
10
+ start_time = Time.now.to_f * 1000
10
11
  request_id = env["action_dispatch.request_id"]
11
12
  Thread.current[:request_id] = request_id
12
13
  Thread.current[:n_plus_one_duration] = 0
@@ -14,7 +15,6 @@ module BuilderApm
14
15
  Thread.current[:db_runtime] = 0
15
16
  Thread.current[:method_tracing] = 0
16
17
  Thread.current[:db_tracing] = 0
17
- start_time = Time.now.to_f * 1000
18
18
 
19
19
  @status, @headers, @response = @app.call(env)
20
20
 
@@ -1,3 +1,3 @@
1
1
  module BuilderApm
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: builder_apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Ketelle
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-20 00:00:00.000000000 Z
11
+ date: 2023-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails