48bcd5248f
Jaeger is a distributed tracing tool. This change adds a "Tracing" link to the performance bar to directly link to a current request in Jaeger. This is useful for two reasons: 1 - it provides affordance to developers that the distributed tracing tool is available, so that it can quickly be discovered. 2 - it allows developers to quickly find a specific trace without having to manually navigate to a second user-interface.
36 lines
1.1 KiB
Ruby
36 lines
1.1 KiB
Ruby
# 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
|
|
|
|
def self.tracing_url_template
|
|
ENV['GITLAB_TRACING_URL']
|
|
end
|
|
|
|
def self.tracing_url_enabled?
|
|
enabled? && tracing_url_template.present?
|
|
end
|
|
|
|
# This will provide a link into the distributed tracing for the current trace,
|
|
# if it has been captured.
|
|
def self.tracing_url
|
|
return unless tracing_url_enabled?
|
|
|
|
tracing_url_template % {
|
|
correlation_id: Gitlab::CorrelationId.current_id.to_s,
|
|
service: Gitlab.process_name
|
|
}
|
|
end
|
|
end
|
|
end
|