railswatch_gem 0.4.0 → 0.4.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: 51d84f78da3a10be4c22945395c3802e6d7e6622fca6da46db2f51a59c73af13
4
- data.tar.gz: '018bf2d1fbaed1fdc4f4e97caf4de19ea4d4a04f70b3e8c149a058c5137d4430'
3
+ metadata.gz: e813b247ee297eccab4b8fc1e2240142bdd0dfe29a49c95bb6e39e2e7ff38ecd
4
+ data.tar.gz: fb805d469b067b639d1e2860f68d0ca51cd2360b544ccce7f9a4b868984fde08
5
5
  SHA512:
6
- metadata.gz: 296307ae6dfc447f56e0c9614d69c236324f23bf1209a2e6a23b1f09ce51885644216b7d99ed5b01fd35b163ac0bc72c161d021a218eba2735b22d9afac7705a
7
- data.tar.gz: 499075bcc71e108cfd42f18c23337a05a32ee1f624ac5e8b1faf9b63bb7addb404e8773646f7fa0ee9799e99cd8bb2819d7cd1fdbe66c4017088b0622a6d505d
6
+ metadata.gz: 66833fbfc3fc437c766c07686167d7224c190876d0d9d4f93431db6fb9a11e6d795ea1fb5f73eeec62c44b9c719fb790c033ce800b12fc2ee2bda9024e138ff9
7
+ data.tar.gz: 1f4e3dac70f8e457c73f944fd63426d09e908c41537719a85f50dad8a86e777065899066342939f8aa853e3069a87d5a45bbfe6ea40306ad3fbf641605a78928
@@ -2,9 +2,6 @@
2
2
 
3
3
  module RailswatchGem
4
4
  class Railtie < ::Rails::Railtie
5
- # Paths that belong to the host application (not gems or Ruby internals)
6
- APP_PATH_PATTERN = %r{/(app|lib|config)/}.freeze
7
- IGNORE_PATH_PATTERN = %r{/vendor/|/railswatch_gem/}.freeze
8
5
  MAX_STACKTRACE_FRAMES = 10
9
6
 
10
7
  config.after_initialize do
@@ -45,6 +42,8 @@ module RailswatchGem
45
42
 
46
43
  initializer "railswatch.query_source_location" do
47
44
  ActiveSupport.on_load(:active_record) do
45
+ app_root = Rails.root.to_s
46
+
48
47
  ActiveSupport::Notifications.subscribe("sql.active_record") do |*, payload|
49
48
  next unless RailswatchGem.config.enabled
50
49
  next unless RailswatchGem.config.track_query_source
@@ -53,9 +52,9 @@ module RailswatchGem
53
52
  next unless span&.recording?
54
53
 
55
54
  frames = caller_locations(0, 40)
56
- .select { |f| f.path.match?(APP_PATH_PATTERN) && !f.path.match?(IGNORE_PATH_PATTERN) }
55
+ .select { |f| f.path.start_with?(app_root) && !f.path.include?("/vendor/") }
57
56
  .first(MAX_STACKTRACE_FRAMES)
58
- .map { |f| "#{f.path}:#{f.lineno} in `#{f.label}`" }
57
+ .map { |f| "#{f.path.delete_prefix(app_root + '/')}:#{f.lineno} in `#{f.label}`" }
59
58
 
60
59
  span.set_attribute("code.stacktrace", frames.join("\n")) if frames.any?
61
60
  rescue => e
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailswatchGem
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railswatch_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Hammett