callstacking-rails 0.1.37 → 0.1.39

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: c8f0e31ee61913c798aa308ed0d92c76b8755cc0f6a884c0530792a23a0632e8
4
- data.tar.gz: 04f3fe70825ec3f94c4d3b2d6c700cb55f457444376ffb066884a80ad4a5fb37
3
+ metadata.gz: 18d409b7fd6bca47f9057af1f92d38e158e602d7cc4aa1c60dc850083f23d975
4
+ data.tar.gz: 6901e6b9dbdf8bc18f4b5469787fcc4e3f4570f5291e2546e0cd61df054e0387
5
5
  SHA512:
6
- metadata.gz: 4b90cd3642f0b451347aae60efe9174400c66c155d2d5f19b719b9a21c73f730c5a0a3748aa2d0d736c9f001d2e9027a070429a7653bb6e4aa112328fc7ee120
7
- data.tar.gz: a42354436d3edbc0d8b02878731435f9b3b2f23b7281f011cae9b8fff8220750d4081fc75572595b132560c75d87de1f150df8a9fb8a4c8ace4f591f40f1af3b
6
+ metadata.gz: 783bcd0a682399ba3565c45acfaa642aa8e98f80ee2b6cc7076f9d9ce6ba95479de69a28365f80764f64cf4b9701a87b7e793601768eb02510ec0ee485b47068
7
+ data.tar.gz: 6b01ddfc45792a3e5f2b34fff44659976e446722fff1bcd72d099f314793675b2ef9b0fc7786bb5b6fd11fff1900ad0e27dae9b5326a2675b67e2e2a0d81f328
@@ -5,12 +5,12 @@ module Callstacking
5
5
  extend ActiveSupport::Concern
6
6
  def callstacking_setup
7
7
  exception = nil
8
- @last_callstacking_sample = TIme.utc.now
8
+ @last_callstacking_sample = Time.now.utc
9
9
  Callstacking::Rails::Engine.start_tracing(self)
10
10
 
11
11
  yield
12
12
  rescue Exception => e
13
- @last_callstacking_exception = Time.utc.now
13
+ @last_callstacking_exception = Time.now.utc
14
14
  exception = e
15
15
  raise e
16
16
  ensure
@@ -42,6 +42,9 @@ module Callstacking
42
42
  path = method(__method__).super_method.source_location&.first || ''
43
43
  line_no = method(__method__).super_method.source_location&.last || ''
44
44
 
45
+ method_source = ''
46
+ method_source = method(__method__).super_method.source if settings.analyze_source?
47
+
45
48
  p, l = caller.find { |c| c.to_s =~ /#{::Rails.root.to_s}/}&.split(':')
46
49
 
47
50
  spans = tmp_module.instance_variable_get(:@spans)
@@ -50,9 +53,9 @@ module Callstacking
50
53
 
51
54
  arguments = Callstacking::Rails::Instrument.arguments_for(method(__method__).super_method, args)
52
55
 
53
- span.call_entry(klass, method_name, arguments, p || path, l || line_no)
56
+ span.call_entry(klass, method_name, arguments, p || path, l || line_no, method_source)
54
57
  return_val = super(*args, &block)
55
- span.call_return(klass, method_name, p || path, l || line_no, return_val)
58
+ span.call_return(klass, method_name, p || path, l || line_no, return_val, method_source)
56
59
 
57
60
  return_val
58
61
  end
@@ -67,6 +70,9 @@ module Callstacking
67
70
  path = method(__method__).super_method.source_location&.first || ''
68
71
  line_no = method(__method__).super_method.source_location&.last || ''
69
72
 
73
+ method_source = ''
74
+ method_source = method(__method__).super_method.source if settings.analyze_source?
75
+
70
76
  p, l = caller.find { |c| c.to_s =~ /#{::Rails.root.to_s}/}&.split(':')
71
77
 
72
78
  spans = tmp_module.instance_variable_get(:@spans)
@@ -75,9 +81,9 @@ module Callstacking
75
81
 
76
82
  arguments = Callstacking::Rails::Instrument.arguments_for(method(__method__).super_method, args)
77
83
 
78
- span.call_entry(klass, method_name, arguments, p || path, l || line_no)
84
+ span.call_entry(klass, method_name, arguments, p || path, l || line_no, method_source)
79
85
  return_val = super(*args, **kwargs, &block)
80
- span.call_return(klass, method_name, p || path, l || line_no, return_val)
86
+ span.call_return(klass, method_name, p || path, l || line_no, return_val, method_source)
81
87
 
82
88
  return_val
83
89
  end
@@ -63,10 +63,15 @@ module Callstacking
63
63
  !enabled?
64
64
  end
65
65
 
66
+ def analyze_source?
67
+ settings[:analyze_source] || false
68
+ end
69
+
66
70
  def save(email, password, url)
67
71
  props = { auth_token: '',
68
72
  url: url,
69
- enabled: true
73
+ enabled: true,
74
+ analyze_source: false,
70
75
  }
71
76
 
72
77
  props = { Callstacking::Rails::Env.environment => {
@@ -18,15 +18,15 @@ module Callstacking
18
18
  @nesting_level
19
19
  end
20
20
 
21
- def call_entry(klass, method_name, arguments, path, line_no)
21
+ def call_entry(klass, method_name, arguments, path, line_no, method_source)
22
22
  @nesting_level+=1
23
23
  @previous_entry = previous_event(klass, method_name)
24
- @call_entry_callback.call(@nesting_level, increment_order_num, klass, method_name, arguments, path, line_no)
24
+ @call_entry_callback.call(@nesting_level, increment_order_num, klass, method_name, arguments, path, line_no, method_source)
25
25
  end
26
26
 
27
- def call_return(klass, method_name, path, line_no, return_val)
27
+ def call_return(klass, method_name, path, line_no, return_val, method_source)
28
28
  @call_return_callback.call(coupled_callee(klass, method_name), @nesting_level,
29
- increment_order_num, klass, method_name, path, line_no, return_val)
29
+ increment_order_num, klass, method_name, path, line_no, return_val, method_source)
30
30
  @nesting_level-=1
31
31
  end
32
32
 
@@ -68,12 +68,12 @@ module Callstacking
68
68
  private
69
69
 
70
70
  def init_callbacks(tuid)
71
- @spans.on_call_entry do |nesting_level, order_num, klass, method_name, arguments, path, line_no|
72
- create_call_entry(tuid, nesting_level, order_num, klass, method_name, arguments, path, line_no, @traces)
71
+ @spans.on_call_entry do |nesting_level, order_num, klass, method_name, arguments, path, line_no, method_source|
72
+ create_call_entry(tuid, nesting_level, order_num, klass, method_name, arguments, path, line_no, @traces, method_source)
73
73
  end
74
74
 
75
- @spans.on_call_return do |coupled_callee, nesting_level, order_num, klass, method_name, path, line_no, return_val|
76
- create_call_return(tuid, coupled_callee, nesting_level, order_num, klass, method_name, path, line_no, return_val, @traces)
75
+ @spans.on_call_return do |coupled_callee, nesting_level, order_num, klass, method_name, path, line_no, return_val, method_source|
76
+ create_call_return(tuid, coupled_callee, nesting_level, order_num, klass, method_name, path, line_no, return_val, @traces, method_source)
77
77
  end
78
78
  end
79
79
 
@@ -97,7 +97,7 @@ module Callstacking
97
97
  "#{exception.backtrace[0]}".html_safe
98
98
  end
99
99
 
100
- def create_call_return(tuid, coupled_callee, nesting_level, order_num, klass, method_name, path, line_no, return_val, traces)
100
+ def create_call_return(tuid, coupled_callee, nesting_level, order_num, klass, method_name, path, line_no, return_val, traces, method_source)
101
101
  lock.synchronize do
102
102
  traces << { tuid: tuid,
103
103
  type: TRACE_CALL_RETURN,
@@ -112,11 +112,12 @@ module Callstacking
112
112
  return_value: return_value(return_val),
113
113
  coupled_callee: coupled_callee,
114
114
  message: nil,
115
+ method_source: method_source,
115
116
  }
116
117
  end
117
118
  end
118
119
 
119
- def create_call_entry(tuid, nesting_level, order_num, klass, method_name, arguments, path, line_no, traces)
120
+ def create_call_entry(tuid, nesting_level, order_num, klass, method_name, arguments, path, line_no, traces, method_source)
120
121
  lock.synchronize do
121
122
  traces << { tuid: tuid,
122
123
  type: TRACE_CALL_ENTRY,
@@ -131,6 +132,7 @@ module Callstacking
131
132
  coupled_callee: nil,
132
133
  local_variables: {},
133
134
  message: nil,
135
+ method_source: method_source,
134
136
  }
135
137
  end
136
138
  end
@@ -150,6 +152,7 @@ module Callstacking
150
152
  return_value: nil,
151
153
  coupled_callee: false,
152
154
  local_variables: {},
155
+ method_source: '',
153
156
  }
154
157
  end
155
158
  end
@@ -1,5 +1,5 @@
1
1
  module Callstacking
2
2
  module Rails
3
- VERSION = "0.1.37"
3
+ VERSION = "0.1.39"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: callstacking-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.37
4
+ version: 0.1.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Jones
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-10 00:00:00.000000000 Z
11
+ date: 2023-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: method_source
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: mocha
57
71
  requirement: !ruby/object:Gem::Requirement