appmap 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ae8f99b6edb988e9ec0e6e3ee31967d754ece4edf7dce0b34d025ff20dcabc9
4
- data.tar.gz: 77311214bb3064101a08664e794550cdcb4759c15a6739780f3aafe76f19bdb2
3
+ metadata.gz: ef590ede8fe883183358cb975bb4531c07ee332de2708bfce4743c4cfc0c7f15
4
+ data.tar.gz: 23d4c0d3c7fa26d5c298186d3e8c9e6318ffe8aa265dcd55358a02ace656db04
5
5
  SHA512:
6
- metadata.gz: c4ea141233301848f5de54bce11a59a69545f364e82dc984c4e6588088350a0ca5f1479acbc4595829c90bf0533ae17aea53b067da9f11bd1488c53b3068ebc6
7
- data.tar.gz: 0c3486071282f8edfbca7bedd3e72efd0f77753c721e48f2e375f65ed8c57c2b8d29558cf0f4d8805309e243f1805417a9d6c66126003124831b2a4f03879343
6
+ metadata.gz: 2dcfac0480a1e5cf59be2bfa03614d141135d1e2a06010e494fd8807e58803b2361627cd861a038cc4ea7b1e21013628ae04e4a75fadc7df877c9c143d5a8f5d
7
+ data.tar.gz: bb9dadf2e3dae77b280497223544ffe84f9fed42cb742ea021e049be311a07f5e79b5715a59c523ff4ca7fff9ed37db301f243b5d6a722cde5d5b44ad8c98fc1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.0.1](https://github.com/getappmap/appmap-ruby/compare/v1.0.0...v1.0.1) (2024-04-30)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Handle exceptions in app.matches? ([0e9db0d](https://github.com/getappmap/appmap-ruby/commit/0e9db0dc6d574785865c8883a85f011635fa1495)), closes [#358](https://github.com/getappmap/appmap-ruby/issues/358)
7
+
1
8
  # [1.0.0](https://github.com/getappmap/appmap-ruby/compare/v0.103.0...v1.0.0) (2024-02-06)
2
9
 
3
10
 
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'appmap/event'
4
- require 'appmap/hook'
5
- require 'appmap/util'
6
- require 'appmap/handler/rails/context'
3
+ require "appmap/event"
4
+ require "appmap/hook"
5
+ require "appmap/util"
6
+ require "appmap/handler/rails/context"
7
+ require "appmap/handler/rails/test_route"
7
8
 
8
9
  module AppMap
9
10
  module Handler
10
11
  module Rails
11
-
12
12
  module RequestHandler
13
13
  class HTTPServerRequest < AppMap::Event::MethodEvent
14
14
  attr_accessor :normalized_path_info, :request_method, :path_info, :params, :headers, :call_elapsed_instrumentation
@@ -19,7 +19,7 @@ module AppMap
19
19
  self.request_method = request.request_method
20
20
  self.normalized_path_info = normalized_path(request)
21
21
  self.headers = AppMap::Util.select_rack_headers(request.env)
22
- self.path_info = request.path_info.split('?')[0]
22
+ self.path_info = request.path_info.split("?")[0]
23
23
  # ActionDispatch::Http::ParameterFilter is deprecated
24
24
  parameter_filter_cls = \
25
25
  if defined?(ActiveSupport::ParameterFilter)
@@ -36,7 +36,7 @@ module AppMap
36
36
  request_method: request_method,
37
37
  path_info: path_info,
38
38
  normalized_path_info: normalized_path_info,
39
- headers: headers,
39
+ headers: headers
40
40
  }.compact
41
41
 
42
42
  unless Util.blank?(params)
@@ -46,7 +46,7 @@ module AppMap
46
46
  name: key,
47
47
  class: val.class.name,
48
48
  value: self.class.display_string(val),
49
- object_id: val.__id__,
49
+ object_id: val.__id__
50
50
  }.tap do |message|
51
51
  AppMap::Event::MethodEvent.add_schema message, val
52
52
  end
@@ -60,9 +60,12 @@ module AppMap
60
60
  def normalized_path(request, router = ::Rails.application.routes.router)
61
61
  # use a cloned environment because the router can modify it
62
62
  request = ActionDispatch::Request.new request.env.clone
63
+
63
64
  router.recognize request do |route, _|
64
65
  app = route.app
65
- next unless app.matches? request
66
+
67
+ next unless Rails.test_route(app, request)
68
+
66
69
  return normalized_path request, app.rack_app.routes.router if app.engine?
67
70
 
68
71
  return AppMap::Util.swaggerize_path(route.path.spec.to_s)
@@ -113,19 +116,19 @@ module AppMap
113
116
  req = receiver.request
114
117
  return unless Context.create req.env
115
118
 
116
- before_hook_start_time = AppMap::Util.gettime()
119
+ before_hook_start_time = AppMap::Util.gettime
117
120
  call_event = HTTPServerRequest.new(req)
118
- call_event.call_elapsed_instrumentation = (AppMap::Util.gettime() - before_hook_start_time)
121
+ call_event.call_elapsed_instrumentation = (AppMap::Util.gettime - before_hook_start_time)
119
122
  # http_server_request events are i/o and do not require a package name.
120
123
  AppMap.tracing.record_event call_event, defined_class: defined_class, method: hook_method
121
124
  call_event
122
125
  end
123
126
 
124
127
  def after_hook(receiver, call_event, elapsed, *)
125
- after_hook_start_time = AppMap::Util.gettime()
128
+ after_hook_start_time = AppMap::Util.gettime
126
129
  return_event = HTTPServerResponse.build_from_invocation \
127
130
  call_event.id, Context.new.find_template_render_value, elapsed, receiver.response
128
- return_event.elapsed_instrumentation = (AppMap::Util.gettime() - after_hook_start_time) + call_event.call_elapsed_instrumentation
131
+ return_event.elapsed_instrumentation = (AppMap::Util.gettime - after_hook_start_time) + call_event.call_elapsed_instrumentation
129
132
  call_event.call_elapsed_instrumentation = nil # to stay consistent with elapsed_instrumentation only being stored in return
130
133
  AppMap.tracing.record_event return_event
131
134
  Context.remove receiver.request.env
@@ -191,28 +194,28 @@ module AppMap
191
194
  @request_id = payload[:request].request_id
192
195
  @subscriber = self.class.instance_method(:after_hook).bind(self)
193
196
 
194
- ActiveSupport::Notifications.subscribe 'process_action.action_controller', @subscriber
197
+ ActiveSupport::Notifications.subscribe "process_action.action_controller", @subscriber
195
198
  before_hook payload
196
199
  end
197
200
 
198
201
  def before_hook(payload)
199
- before_hook_start_time = AppMap::Util.gettime()
202
+ before_hook_start_time = AppMap::Util.gettime
200
203
  @call_event = HTTPServerRequest.new payload[:request]
201
- @call_event.call_elapsed_instrumentation = (AppMap::Util.gettime() - before_hook_start_time)
204
+ @call_event.call_elapsed_instrumentation = (AppMap::Util.gettime - before_hook_start_time)
202
205
  AppMap.tracing.record_event @call_event
203
206
  end
204
207
 
205
208
  def after_hook(_name, started, finished, _unique_id, payload)
206
209
  return unless @request_id == payload[:request].request_id
207
210
 
208
- after_hook_start_time = AppMap::Util.gettime()
211
+ after_hook_start_time = AppMap::Util.gettime
209
212
  return_event = HTTPServerResponse.build_from_invocation(
210
213
  @call_event.id,
211
214
  Context.new.find_template_render_value,
212
215
  finished - started,
213
216
  payload[:response] || payload
214
217
  )
215
- return_event.elapsed_instrumentation = (AppMap::Util.gettime() - after_hook_start_time) + @call_event.call_elapsed_instrumentation
218
+ return_event.elapsed_instrumentation = (AppMap::Util.gettime - after_hook_start_time) + @call_event.call_elapsed_instrumentation
216
219
 
217
220
  AppMap.tracing.record_event return_event
218
221
  Context.remove payload[:request].env
@@ -0,0 +1,26 @@
1
+ module AppMap
2
+ module Handler
3
+ module Rails
4
+ class << self
5
+ def test_route(app, request)
6
+ app.matches?(request)
7
+ rescue
8
+ test_route_warn(request)
9
+ false
10
+ end
11
+
12
+ protected
13
+
14
+ @test_route_warned = false
15
+
16
+ def test_route_warn(request)
17
+ return if @test_route_warned
18
+
19
+ @test_route_warned = true
20
+ warn "Notice: Failed to match route for #{request&.path_info || "an unknown path"}: #{$ERROR_INFO}"
21
+ warn "Notice: A solution for this problem is forthcoming, see https://github.com/getappmap/appmap-ruby/issues/360"
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -3,7 +3,7 @@
3
3
  module AppMap
4
4
  URL = 'https://github.com/applandinc/appmap-ruby'
5
5
 
6
- VERSION = '1.0.0'
6
+ VERSION = '1.0.1'
7
7
 
8
8
  APPMAP_FORMAT_VERSION = '1.12.0'
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: 1.0.0
4
+ version: 1.0.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: 2024-02-06 00:00:00.000000000 Z
11
+ date: 2024-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: method_source
@@ -305,7 +305,6 @@ extensions:
305
305
  extra_rdoc_files: []
306
306
  files:
307
307
  - ".dockerignore"
308
- - ".github/workflows/main.yml"
309
308
  - ".gitignore"
310
309
  - ".nvmrc"
311
310
  - ".rbenv-gemsets"
@@ -398,6 +397,7 @@ files:
398
397
  - lib/appmap/handler/rails/request_handler.rb
399
398
  - lib/appmap/handler/rails/sql_handler.rb
400
399
  - lib/appmap/handler/rails/template.rb
400
+ - lib/appmap/handler/rails/test_route.rb
401
401
  - lib/appmap/hook.rb
402
402
  - lib/appmap/hook/method.rb
403
403
  - lib/appmap/hook/method/ruby2.rb
@@ -1,16 +0,0 @@
1
- name: Add new issues to project tracker
2
-
3
- on:
4
- issues:
5
- types:
6
- - opened
7
-
8
- jobs:
9
- add-to-project:
10
- name: Add issue to project
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/add-to-project@main
14
- with:
15
- project-url: https://github.com/orgs/getappmap/projects/15
16
- github-token: ${{ secrets.ADD_TO_PROJECT_BOARD_PAT }}