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 +4 -4
- data/lib/rails_otel_context/version.rb +1 -1
- data/lib/rails_otel_context.rb +22 -9
- 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: 85776a38085568bcfb92c95343e435b3c3838d7e215c75d4242397c136b3aaed
|
|
4
|
+
data.tar.gz: dec0e60af1f7757c68788ed55475cf9cead5bb8d3a3c7f15461708be3b8edf6f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4ea73be1284f26a3e18984aef619a51f8812861ab75305165e8a5eb2218c7149baacaca130081e2f2a2e90e3054f2e9aca2d1a5724f86365d502a6dcddde109a
|
|
7
|
+
data.tar.gz: 3945fff4851e07829f334a9b7170ed116c206cb52f84d432bff81a188447b1c25d17a25122983912b21da380af4efd01a6915def6bfdedef4b317a4c13ee273d
|
data/lib/rails_otel_context.rb
CHANGED
|
@@ -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!.
|
|
55
|
-
# SDK
|
|
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
|
|
59
|
-
# RailsOtelContext.install_processor! #
|
|
59
|
+
# OpenTelemetry::SDK.configure { … } # second SDK configure (replaces provider)
|
|
60
|
+
# RailsOtelContext.install_processor! # re-registers on the new provider
|
|
60
61
|
#
|
|
61
|
-
#
|
|
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
|
|
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
|
-
@
|
|
80
|
+
@processor_registered_on = provider
|
|
68
81
|
processor = RailsOtelContext::CallContextProcessor.new(app_root: Rails.root)
|
|
69
|
-
|
|
82
|
+
provider.add_span_processor(processor)
|
|
70
83
|
end
|
|
71
84
|
|
|
72
85
|
private
|