rails-otel-context 0.9.9 → 0.9.10

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: 4eb35396c5cddc8f420624441b7f2bdacf2d1ef005510db0855cb9803cfb4635
4
- data.tar.gz: e8a3ffbb994abad920bf7ccbc66903777d380952711237ca4ce0cd7ef153c7c0
3
+ metadata.gz: 85776a38085568bcfb92c95343e435b3c3838d7e215c75d4242397c136b3aaed
4
+ data.tar.gz: dec0e60af1f7757c68788ed55475cf9cead5bb8d3a3c7f15461708be3b8edf6f
5
5
  SHA512:
6
- metadata.gz: b1c75e3474d1d922f96427658daafbe73b7ca41e9f8f59a6654f7cc2ef4576a7d055287d1fb95b75161a1c178848350672f7b05f798ef080aef50236d6d36824
7
- data.tar.gz: e2708c7b6dfa266cd62f66d7b302f54aa181108b47fa7fc589fe5e5a0645a42bab0a4d73753f3fd3c326df24c99280052b025808995cda86815662d7848bb573
6
+ metadata.gz: 4ea73be1284f26a3e18984aef619a51f8812861ab75305165e8a5eb2218c7149baacaca130081e2f2a2e90e3054f2e9aca2d1a5724f86365d502a6dcddde109a
7
+ data.tar.gz: 3945fff4851e07829f334a9b7170ed116c206cb52f84d432bff81a188447b1c25d17a25122983912b21da380af4efd01a6915def6bfdedef4b317a4c13ee273d
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsOtelContext
4
- VERSION = '0.9.9'
4
+ VERSION = '0.9.10'
5
5
  end
@@ -51,22 +51,35 @@ module RailsOtelContext
51
51
  end
52
52
 
53
53
  # Registers CallContextProcessor with the OTel tracer_provider.
54
- # Called automatically by install!. Call this manually only when the OTel
55
- # SDK is configured after install! has already run (rare):
54
+ # Called automatically by install!. Safe to call manually after a second
55
+ # OpenTelemetry::SDK.configure call replaces the tracer_provider the
56
+ # method detects the provider change and re-registers automatically:
56
57
  #
57
58
  # RailsOtelContext.install! # hooks up AR/request context
58
- # OpenTelemetry::SDK.configure { … } # SDK configured later
59
- # RailsOtelContext.install_processor! # add processor to the now-real provider
59
+ # OpenTelemetry::SDK.configure { … } # second SDK configure (replaces provider)
60
+ # RailsOtelContext.install_processor! # re-registers on the new provider
60
61
  #
61
- # Safe to call multiple times idempotent.
62
+ # Idempotent per provider instance: re-registers when OpenTelemetry::SDK.configure
63
+ # is called again (which replaces the global tracer_provider with a new object),
64
+ # but skips registration when called multiple times against the same provider.
62
65
  def install_processor!
63
- return if @processor_installed
64
66
  return unless defined?(Rails) && Rails.root
65
- return unless OpenTelemetry.tracer_provider.respond_to?(:add_span_processor)
67
+ return unless defined?(OpenTelemetry)
68
+
69
+ # Capture once: tracer_provider is a global that SDK.configure can replace
70
+ # on another thread. A single local read makes the rest of the method consistent.
71
+ provider = OpenTelemetry.tracer_provider
72
+ return unless provider.respond_to?(:add_span_processor)
73
+
74
+ # Use object identity, not a boolean flag. SDK.configure creates a new
75
+ # TracerProvider instance each time, so equal? detects provider replacement
76
+ # and triggers re-registration, while guarding against double-registration
77
+ # on the same provider.
78
+ return if @processor_registered_on.equal?(provider)
66
79
 
67
- @processor_installed = true
80
+ @processor_registered_on = provider
68
81
  processor = RailsOtelContext::CallContextProcessor.new(app_root: Rails.root)
69
- OpenTelemetry.tracer_provider.add_span_processor(processor)
82
+ provider.add_span_processor(processor)
70
83
  end
71
84
 
72
85
  private
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.9.9
4
+ version: 0.9.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Last9