appmap 0.65.0 → 0.65.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: 9ff92977defe997917c8b7c2d9d5974d5e743c02b637bcfffa5548e087d4644f
4
- data.tar.gz: 4889a8d717b0167737719acc75c12f5709404b6445b6dd633523cd76e4992a96
3
+ metadata.gz: 30c93c7dbd38cd355d2512f43d177243bba4c184e81c588bf2f99e3b7d2426f4
4
+ data.tar.gz: 3dd70314c48d4df781dcda082fb293260d04725228e66c4c3323ebdcb09ea35a
5
5
  SHA512:
6
- metadata.gz: 4a78ced9dc2d5c0e80fe0f68d01508cff0af59bfc65f9a747ec5f981d7bd5a7523a59230427ddf465b39db1768f2443c856a93c852ddb444bc80eec4a539f460
7
- data.tar.gz: 21a54adacd2b5b27a5f2a6143db0c0684716a9d1db6add75d4e05fdd73054bb9576fc2bac3ce68067230d1fb04caf177c8e4366e05a061301bd1a9dd84214bf5
6
+ metadata.gz: bea8dc7d3e1f05cca6ae264b7b0cf8ab6cdddfd366c59f09131c9c98cd12989e2878f276fc01360166ccee6c16b040b6ecd3aa8c6e913407bbd93d4bb1928862
7
+ data.tar.gz: 5a798b37f59f39f70e69398e0d64353f66baf4b55000b45dc951be27830b04f36d17c2fe58bc4f5e86fdab368c056b90834c15a21f438535f8403ec437758d8d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.65.1](https://github.com/applandinc/appmap-ruby/compare/v0.65.0...v0.65.1) (2021-09-16)
2
+
3
+
4
+ ### Performance Improvements
5
+
6
+ * Cache method metadata ([d11e0f3](https://github.com/applandinc/appmap-ruby/commit/d11e0f3361057b7cada204656ca833c12bb704c1))
7
+ * Don't scan the backtrace on every SQL query ([9bb7457](https://github.com/applandinc/appmap-ruby/commit/9bb74576d24f7954a388f09f33e69ae9d11a4188))
8
+
1
9
  # [0.65.0](https://github.com/applandinc/appmap-ruby/compare/v0.64.0...v0.65.0) (2021-09-14)
2
10
 
3
11
 
data/lib/appmap/event.rb CHANGED
@@ -53,7 +53,7 @@ module AppMap
53
53
  @times[best_class_name(value)] += elapsed
54
54
  end
55
55
 
56
- encode_dislay_string(value_string)
56
+ encode_display_string(value_string)
57
57
  end
58
58
 
59
59
  def object_properties(hash_like)
@@ -77,7 +77,7 @@ module AppMap
77
77
  value_cls.name
78
78
  end
79
79
 
80
- def encode_dislay_string(value)
80
+ def encode_display_string(value)
81
81
  (value||'')[0...LIMIT].encode('utf-8', invalid: :replace, undef: :replace, replace: '_')
82
82
  end
83
83
 
@@ -138,22 +138,46 @@ module AppMap
138
138
  class MethodCall < MethodEvent
139
139
  attr_accessor :defined_class, :method_id, :path, :lineno, :parameters, :receiver, :static
140
140
 
141
+ MethodMetadata = Struct.new(:defined_class, :method_id, :path, :lineno, :static)
142
+
143
+ @@method_metadata = {}
144
+
141
145
  class << self
146
+ private
147
+
148
+ def method_metadata(defined_class, method, receiver)
149
+ result = @@method_metadata[method]
150
+ return result if result
151
+
152
+ result = MethodMetadata.new
153
+ result.static = receiver.is_a?(Module)
154
+ result.defined_class = defined_class
155
+ result.method_id = method.name.to_s
156
+ if method.source_location
157
+ path = method.source_location[0]
158
+ path = path[Dir.pwd.length + 1..-1] if path.index(Dir.pwd) == 0
159
+ result.path = path
160
+ result.lineno = method.source_location[1]
161
+ else
162
+ result.path = [ defined_class, result.static ? '.' : '#', method.name ].join
163
+ end
164
+ @@method_metadata[method] = result
165
+ end
166
+
167
+ public
168
+
142
169
  def build_from_invocation(defined_class, method, receiver, arguments, event: MethodCall.new)
143
170
  event ||= MethodCall.new
144
171
  defined_class ||= 'Class'
172
+
145
173
  event.tap do
146
- static = receiver.is_a?(Module)
147
- event.defined_class = defined_class
148
- event.method_id = method.name.to_s
149
- if method.source_location
150
- path = method.source_location[0]
151
- path = path[Dir.pwd.length + 1..-1] if path.index(Dir.pwd) == 0
152
- event.path = path
153
- event.lineno = method.source_location[1]
154
- else
155
- event.path = [ defined_class, static ? '.' : '#', method.name ].join
156
- end
174
+ metadata = method_metadata(defined_class, method, receiver)
175
+
176
+ event.defined_class = metadata.defined_class
177
+ event.method_id = metadata.method_id
178
+ event.path = metadata.path
179
+ event.lineno = metadata.lineno
180
+ event.static = metadata.static
157
181
 
158
182
  # Check if the method has key parameters. If there are any they'll always be last.
159
183
  # If yes, then extract it from arguments.
@@ -186,7 +210,7 @@ module AppMap
186
210
  object_id: receiver.__id__,
187
211
  value: display_string(receiver)
188
212
  }
189
- event.static = static
213
+
190
214
  MethodEvent.build_from_invocation(:call, event: event)
191
215
  end
192
216
  end
@@ -109,34 +109,6 @@ module AppMap
109
109
  begin
110
110
  sql = payload[:sql].strip
111
111
 
112
- # Detect whether a function call within a specified filename is present in the call stack.
113
- find_in_backtrace = lambda do |file_name, function_name = nil|
114
- Thread.current.backtrace.find do |line|
115
- tokens = line.split(':')
116
- matches_file = tokens.find { |t| t.rindex(file_name) == (t.length - file_name.length) }
117
- matches_function = function_name.nil? || tokens.find { |t| t == "in `#{function_name}'" }
118
- matches_file && matches_function
119
- end
120
- end
121
-
122
- # Ignore SQL calls which are made while establishing a new connection.
123
- #
124
- # Example:
125
- # /path/to/ruby/2.6.0/gems/sequel-5.20.0/lib/sequel/connection_pool.rb:122:in `make_new'
126
- return if find_in_backtrace.call('lib/sequel/connection_pool.rb', 'make_new')
127
- # lib/active_record/connection_adapters/abstract/connection_pool.rb:811:in `new_connection'
128
- return if find_in_backtrace.call('lib/active_record/connection_adapters/abstract/connection_pool.rb', 'new_connection')
129
-
130
- # Ignore SQL calls which are made while inspecting the DB schema.
131
- #
132
- # Example:
133
- # /path/to/ruby/2.6.0/gems/sequel-5.20.0/lib/sequel/model/base.rb:812:in `get_db_schema'
134
- return if find_in_backtrace.call('lib/sequel/model/base.rb', 'get_db_schema')
135
- # /usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/model_schema.rb:466:in `load_schema!'
136
- return if find_in_backtrace.call('lib/active_record/model_schema.rb', 'load_schema!')
137
- return if find_in_backtrace.call('lib/active_model/attribute_methods.rb', 'define_attribute_methods')
138
- return if find_in_backtrace.call('lib/active_record/connection_adapters/schema_cache.rb')
139
-
140
112
  SQLExaminer.examine payload, sql: sql
141
113
 
142
114
  call = SQLCall.new(payload)
@@ -3,7 +3,7 @@
3
3
  module AppMap
4
4
  URL = 'https://github.com/applandinc/appmap-ruby'
5
5
 
6
- VERSION = '0.65.0'
6
+ VERSION = '0.65.1'
7
7
 
8
8
  APPMAP_FORMAT_VERSION = '1.5.1'
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.65.0
4
+ version: 0.65.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Gilpin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-14 00:00:00.000000000 Z
11
+ date: 2021-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport