Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Newdigate <andrew@gitlab.com>2019-01-07 13:40:54 +0300
committerAndrew Newdigate <andrew@gitlab.com>2019-01-17 13:32:44 +0300
commit57a8859a11fe0c2cbd68deb83a2d2857c245fd2f (patch)
tree26728a2ac8d0dd6937de95e1de0711640de788d7 /lib/gitlab/tracing.rb
parentf383c4032a6b3f2ee2c9e5aa50425fc3a04bc1b4 (diff)
Conditionally initialize the global opentracing tracer
This change will instantiate an OpenTracing tracer and configure it as the global tracer when the GITLAB_TRACING environment variable is configured. GITLAB_TRACING takes a "connection string"-like value, encapsulating the driver (eg jaeger, etc) and options for the driver. Since each service, whether it's written in Ruby or Golang, uses the same connection-string, it should be very easy to configure all services in a cluster, or even a single development machine to be setup to use tracing. Note that this change does not include instrumentation or propagation changes as this is a way of breaking a previous larger change into components. The instrumentation and propagation changes will follow in separate changes.
Diffstat (limited to 'lib/gitlab/tracing.rb')
-rw-r--r--lib/gitlab/tracing.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/gitlab/tracing.rb b/lib/gitlab/tracing.rb
new file mode 100644
index 00000000000..3c4db42ac06
--- /dev/null
+++ b/lib/gitlab/tracing.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Tracing
+ # Only enable tracing when the `GITLAB_TRACING` env var is configured. Note that we avoid using ApplicationSettings since
+ # the same environment variable needs to be configured for Workhorse, Gitaly and any other components which
+ # emit tracing. Since other components may start before Rails, and may not have access to ApplicationSettings,
+ # an env var makes more sense.
+ def self.enabled?
+ connection_string.present?
+ end
+
+ def self.connection_string
+ ENV['GITLAB_TRACING']
+ end
+ end
+end