debian-mirror-gitlab/config/initializers/tracing.rb

40 lines
1.3 KiB
Ruby
Raw Normal View History

2019-03-02 22:35:43 +05:30
# frozen_string_literal: true
2019-07-31 22:56:46 +05:30
if Labkit::Tracing.enabled?
2019-03-02 22:35:43 +05:30
Rails.application.configure do |config|
2019-07-31 22:56:46 +05:30
config.middleware.insert_after Gitlab::Middleware::CorrelationId, ::Labkit::Tracing::RackMiddleware
2019-03-02 22:35:43 +05:30
end
# Instrument the Sidekiq client
Sidekiq.configure_client do |config|
config.client_middleware do |chain|
2019-07-31 22:56:46 +05:30
chain.add Labkit::Tracing::Sidekiq::ClientMiddleware
2019-03-02 22:35:43 +05:30
end
end
# Instrument Sidekiq server calls when running Sidekiq server
if Sidekiq.server?
Sidekiq.configure_server do |config|
config.server_middleware do |chain|
2019-07-31 22:56:46 +05:30
chain.add Labkit::Tracing::Sidekiq::ServerMiddleware
2019-03-02 22:35:43 +05:30
end
end
end
2019-12-04 20:38:33 +05:30
# Instrument Redis
Labkit::Tracing::Redis.instrument
2019-03-02 22:35:43 +05:30
# Instrument Rails
2019-07-31 22:56:46 +05:30
Labkit::Tracing::Rails::ActiveRecordSubscriber.instrument
Labkit::Tracing::Rails::ActionViewSubscriber.instrument
2019-12-04 20:38:33 +05:30
Labkit::Tracing::Rails::ActiveSupportSubscriber.instrument
2019-03-02 22:35:43 +05:30
# In multi-processed clustered architectures (puma, unicorn) don't
# 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-07-31 22:56:46 +05:30
tracer = Labkit::Tracing::Factory.create_tracer(Gitlab.process_name, Labkit::Tracing.connection_string)
2019-03-02 22:35:43 +05:30
OpenTracing.global_tracer = tracer if tracer
end
end