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 +4 -4
- data/lib/railswatch_gem/query_source_processor.rb +16 -2
- data/lib/railswatch_gem/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e1412167d3260e84e0b79c29cb804cbd2367d1c649e628600187ad299515cdd0
|
|
4
|
+
data.tar.gz: 03ad36695d1d39f2cbeaf43013b683cc6024fcd3d7c60e9d273b692771c82066
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
33
|
+
raw_frames = caller_locations(0, 50)
|
|
32
34
|
.select { |f| f.path.start_with?(@app_root) && !f.path.include?("/vendor/") }
|
|
33
|
-
|
|
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?
|