Skip to content

Commit 6c62a01

Browse files
committed
BAU: configure OpenTelemetry ID Generator
We need to use the XRay ID generator when using the XRay propagator, in order to generate trace IDs in the correct format. As we're configuring the propagator via the OTEL_PROPAGATORS environment variable, we can gate the ID generator configuration behind the same variable to keep things agnostic. This can only be done via code, so we have to add this to the OpenTelemetry SDK configuration in an initializer. see: https://arc.net/l/quote/ctffkmlm
1 parent 53ba2aa commit 6c62a01

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

config/initializers/opentelemetry.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
instrumentation_config = { "OpenTelemetry::Instrumentation::Rack" => { untraced_endpoints: ["/up"] } }
88
c.use_all(instrumentation_config)
99

10+
if ENV["OTEL_PROPAGATORS"] == "xray"
11+
# The ID Generator can only be configured through code. Gate it behind the propagator env var to keep things agnostic.
12+
c.id_generator = OpenTelemetry::Propagator::XRay::IDGenerator
13+
end
14+
1015
# Disable logging for Rake tasks to avoid cluttering output
1116
c.logger = Logger.new(File::NULL) if Rails.const_defined?(:Rake) && Rake.application.top_level_tasks.any?
1217
end

0 commit comments

Comments
 (0)