rails-otel-context 0.8.0 → 0.8.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3591d00a6587ead8c6abae8400911722b3b7e3802570dd0dcd65abc8ec2c1e79
|
|
4
|
+
data.tar.gz: 96fc8db0139458f2baa708e9b518ee70ffb35594257d321390188f6f26c14176
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e3c445ff373ed66d3693a26534090c24a9f1ab737c575a050c935659e575b3c466ab70d03d599d6dd0ef5a555388d7ec36ab5a41ddf496b2eb9a10577a1472d1
|
|
7
|
+
data.tar.gz: 3aa56abef92ecca9159f54495a73f73c5d0e57347020d3163318b83135d58e1b308c2565d8cfa1651a33dd865d233601cf0932466e700f88765d130408a58ecb
|
|
@@ -61,7 +61,6 @@ module RailsOtelContext
|
|
|
61
61
|
|
|
62
62
|
def apply_call_context(span)
|
|
63
63
|
# Fast path: caller pushed a frame explicitly — O(1), zero allocations.
|
|
64
|
-
# DB adapters will overwrite this with the exact call site post-query.
|
|
65
64
|
pushed = FrameContext.current
|
|
66
65
|
if pushed
|
|
67
66
|
span.set_attribute('code.namespace', pushed[:class_name])
|
|
@@ -69,8 +68,7 @@ module RailsOtelContext
|
|
|
69
68
|
return
|
|
70
69
|
end
|
|
71
70
|
|
|
72
|
-
# Fallback: walk the call stack
|
|
73
|
-
# path; the adapter's post-query walk (shallower) will overwrite the result.
|
|
71
|
+
# Fallback: walk the call stack to find the first app-code frame.
|
|
74
72
|
return unless Thread.respond_to?(:each_caller_location)
|
|
75
73
|
|
|
76
74
|
site = call_site_for_app
|
|
@@ -18,6 +18,21 @@ module RailsOtelContext
|
|
|
18
18
|
processor = RailsOtelContext::CallContextProcessor.new(app_root: Rails.root)
|
|
19
19
|
OpenTelemetry.tracer_provider.add_span_processor(processor)
|
|
20
20
|
end
|
|
21
|
+
|
|
22
|
+
# Warm the table→model map once at boot (after eager_load! in production so
|
|
23
|
+
# all descendants are available). Without this, the first SQL-named span on a
|
|
24
|
+
# cold boot hits an empty map and falls through without model context.
|
|
25
|
+
ActiveSupport.on_load(:active_record) do
|
|
26
|
+
RailsOtelContext::ActiveRecordContext.ar_table_model_map
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Reset the table→model map after every code reload in development.
|
|
31
|
+
# In development, classes are lazy-loaded so the map built on first access
|
|
32
|
+
# may be empty or stale. to_prepare runs after each reload when all currently
|
|
33
|
+
# referenced models are loaded, guaranteeing a fresh index.
|
|
34
|
+
config.to_prepare do
|
|
35
|
+
RailsOtelContext::ActiveRecordContext.reset_ar_table_model_map!
|
|
21
36
|
end
|
|
22
37
|
|
|
23
38
|
# Push the controller class + action name as the active frame for every
|