2019-01-07 05:40:54 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-02-18 15:57:22 -05:00
|
|
|
if Labkit::Tracing.enabled?
|
2019-01-07 05:40:54 -05:00
|
|
|
Rails.application.configure do |config|
|
2020-10-30 05:08:39 -04:00
|
|
|
# Rack needs to parse multipart messages before ActionDispatch can filter parameters
|
|
|
|
config.middleware.insert_after Rack::MethodOverride, ::Labkit::Tracing::RackMiddleware
|
2019-01-07 05:40:54 -05:00
|
|
|
end
|
|
|
|
|
2019-08-23 06:11:19 -04:00
|
|
|
# Instrument Redis
|
|
|
|
Labkit::Tracing::Redis.instrument
|
2021-01-22 10:09:08 -05:00
|
|
|
Labkit::Tracing::ExternalHttp.instrument
|
2019-08-23 06:11:19 -04:00
|
|
|
|
2019-01-23 09:53:23 -05:00
|
|
|
# Instrument Rails
|
2019-02-18 15:57:22 -05:00
|
|
|
Labkit::Tracing::Rails::ActiveRecordSubscriber.instrument
|
|
|
|
Labkit::Tracing::Rails::ActionViewSubscriber.instrument
|
2019-08-23 06:11:19 -04:00
|
|
|
Labkit::Tracing::Rails::ActiveSupportSubscriber.instrument
|
2019-01-23 09:53:23 -05:00
|
|
|
|
2021-05-19 08:10:33 -04:00
|
|
|
# In multi-processed clustered architectures (e.g. Puma cluster) don't
|
2019-01-07 05:40:54 -05:00
|
|
|
# start tracing until the worker processes are spawned. This works
|
|
|
|
# around issues when the opentracing implementation spawns threads
|
|
|
|
Gitlab::Cluster::LifecycleEvents.on_worker_start do
|
2019-02-18 15:57:22 -05:00
|
|
|
tracer = Labkit::Tracing::Factory.create_tracer(Gitlab.process_name, Labkit::Tracing.connection_string)
|
2019-01-07 05:40:54 -05:00
|
|
|
OpenTracing.global_tracer = tracer if tracer
|
|
|
|
end
|
|
|
|
end
|