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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
1.1 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|
2021-01-29 00:20:46 +05:30
# Rack needs to parse multipart messages before ActionDispatch can filter parameters
config.middleware.insert_after Rack::MethodOverride, ::Labkit::Tracing::RackMiddleware
2019-03-02 22:35:43 +05:30
end
2023-06-20 00:43:36 +05:30
# Instrument external calls
2021-03-11 19:13:27 +05:30
Labkit::Tracing::ExternalHttp.instrument
2023-06-20 00:43:36 +05:30
Labkit::Tracing::Redis.instrument if ENV['GITLAB_TRACING_TRACK_REDIS'].present?
2019-12-04 20:38:33 +05:30
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
2023-06-20 00:43:36 +05:30
Labkit::Tracing::Rails::ActiveSupportSubscriber.instrument if ENV['GITLAB_TRACING_TRACK_CACHES'].present?
2019-03-02 22:35:43 +05:30
2021-09-04 01:27:46 +05:30
# In multi-processed clustered architectures (e.g. Puma cluster) don't
2019-03-02 22:35:43 +05:30
# 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