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: f9939fbc8981d0be3075a1c3f7dcbda1c87a0b0d40a5dc9186ace04aa05ef3aa
4
- data.tar.gz: 88a58856ae020819ec9c17e5027d1b24b3c5da1d4609d3c43b909fa1e88df979
3
+ metadata.gz: 3591d00a6587ead8c6abae8400911722b3b7e3802570dd0dcd65abc8ec2c1e79
4
+ data.tar.gz: 96fc8db0139458f2baa708e9b518ee70ffb35594257d321390188f6f26c14176
5
5
  SHA512:
6
- metadata.gz: dc0385bb7df75a0e678dcf03e1b77fa6826427395504bea021e11282f4f1d9f67aadbae64f59cef0d971fe3a6ac2f3208c81d60ea8ef953e316f9196a2ad5c20
7
- data.tar.gz: 468262bd9bf9b9df37705e0aab8d5f39b3610b5754407c4f6f1220594b297eba8f01b3538ddb6fa71ff5e037b4551f7bce97c30e9dac565b500b7c956fb79d54
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. DB spans without a pushed frame take this
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsOtelContext
4
- VERSION = '0.8.0'
4
+ VERSION = '0.8.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-otel-context
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Last9