File: tracing.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (25 lines) | stat: -rw-r--r-- 1,124 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

if Labkit::Tracing.enabled?
  Rails.application.configure do |config|
    # Rack needs to parse multipart messages before ActionDispatch can filter parameters
    config.middleware.insert_after Rack::MethodOverride, ::Labkit::Tracing::RackMiddleware
  end

  # Instrument external calls
  Labkit::Tracing::ExternalHttp.instrument
  Labkit::Tracing::Redis.instrument if ENV['GITLAB_TRACING_TRACK_REDIS'].present?

  # Instrument Rails
  Labkit::Tracing::Rails::ActiveRecordSubscriber.instrument
  Labkit::Tracing::Rails::ActionViewSubscriber.instrument
  Labkit::Tracing::Rails::ActiveSupportSubscriber.instrument if ENV['GITLAB_TRACING_TRACK_CACHES'].present?

  # In multi-processed clustered architectures (e.g. Puma cluster) 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
    tracer = Labkit::Tracing::Factory.create_tracer(Gitlab.process_name, Labkit::Tracing.connection_string)
    OpenTracing.global_tracer = tracer if tracer
  end
end