railswatch_gem 0.4.4 → 0.4.5

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: 9b3439fd5d48760c3599766306225ebbdd327aa788188610d0136ab1ab8ef77d
4
- data.tar.gz: 7327398ee3169bf5977116e61105f0b670f3372283fe52bbf9485eaf0353c372
3
+ metadata.gz: e1412167d3260e84e0b79c29cb804cbd2367d1c649e628600187ad299515cdd0
4
+ data.tar.gz: 03ad36695d1d39f2cbeaf43013b683cc6024fcd3d7c60e9d273b692771c82066
5
5
  SHA512:
6
- metadata.gz: 6f47c4d3e23c9a932c4d6d5ad9cda255cc3de07c9f4b5efb0c6948cc5b968311df35b25543b82f2c665f80121b12a1be49cd3d4eb4c7ef9c3bc29ab9d1b23ec6
7
- data.tar.gz: 41a360ebcc864aee64941cee57d2bbc565931ebf6a158b82076a07ce438c92c443817a9da8ea074d85df05ffe441ade6120c8ec67950eb1479cb7a8cd7bd72e7
6
+ metadata.gz: 4e296fb462b136d7fea292d0656701b03b1b79b6572f9873e3668020aba90b697000a455c37fdf36a54c201cfa43bd8a653e8d009a01bef648d639a454a670a7
7
+ data.tar.gz: c7122fa7cadb8ace87b0d95ec06a2ab919f4e196b81edf2e462c832479c35626b633f424773942934580b761549aa6942cc441e5244e4a0089ef4427a44c3c45
@@ -16,6 +16,8 @@ module RailswatchGem
16
16
  OpenTelemetry::Instrumentation::Trilogy
17
17
  ].freeze
18
18
 
19
+ FRAMEWORK_PATTERNS = %r{/active_record/|/activerecord/|/action_dispatch/|/rack/|/railswatch_gem/}
20
+
19
21
  def initialize(app_root)
20
22
  @app_root = app_root.to_s
21
23
  @app_prefix = "#{@app_root}/"
@@ -28,9 +30,21 @@ module RailswatchGem
28
30
  scope_name = span.instrumentation_scope&.name.to_s
29
31
  return unless DB_SCOPES.include?(scope_name)
30
32
 
31
- frames = caller_locations(0, 50)
33
+ raw_frames = caller_locations(0, 50)
32
34
  .select { |f| f.path.start_with?(@app_root) && !f.path.include?("/vendor/") }
33
- .first(MAX_FRAMES)
35
+
36
+ # First app-level frame (skip framework internals)
37
+ app_frame = raw_frames.find { |f| !f.path.match?(FRAMEWORK_PATTERNS) }
38
+
39
+ if app_frame
40
+ relative_path = app_frame.path.delete_prefix(@app_prefix)
41
+ span.set_attribute("code.filepath", relative_path)
42
+ span.set_attribute("code.lineno", app_frame.lineno)
43
+ span.set_attribute("code.function", app_frame.label.to_s)
44
+ end
45
+
46
+ # Full stacktrace for drill-down
47
+ frames = raw_frames.first(MAX_FRAMES)
34
48
  .map { |f| "#{f.path.delete_prefix(@app_prefix)}:#{f.lineno} in `#{f.label}`" }
35
49
 
36
50
  span.set_attribute("code.stacktrace", frames.join("\n")) if frames.any?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailswatchGem
4
- VERSION = "0.4.4"
4
+ VERSION = "0.4.5"
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.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Hammett