lib/labkit/tracing.rb in gitlab-labkit-0.0.6 vs lib/labkit/tracing.rb in gitlab-labkit-0.1.0.pre.1.pre.gcb57c95
- old
+ new
@@ -1,43 +1,31 @@
# frozen_string_literal: true
-require 'active_support/all'
+require "active_support/all"
module Labkit
+ # Tracing provides distributed tracing functionality
module Tracing
- autoload :Common, 'labkit/tracing/common'
- autoload :Factory, 'labkit/tracing/factory'
- autoload :GRPCInterceptor, 'labkit/tracing/grpc_interceptor'
- autoload :JaegerFactory, 'labkit/tracing/jaeger_factory'
- autoload :RackMiddleware, 'labkit/tracing/rack_middleware'
+ autoload :Common, "labkit/tracing/common"
+ autoload :Factory, "labkit/tracing/factory"
+ autoload :GRPCInterceptor, "labkit/tracing/grpc_interceptor"
+ autoload :JaegerFactory, "labkit/tracing/jaeger_factory"
+ autoload :RackMiddleware, "labkit/tracing/rack_middleware"
+ autoload :Rails, "labkit/tracing/rails"
+ autoload :Sidekiq, "labkit/tracing/sidekiq"
- module Rails
- autoload :ActionViewSubscriber, 'labkit/tracing/rails/action_view_subscriber'
- autoload :ActiveRecordSubscriber, 'labkit/tracing/rails/active_record_subscriber'
- autoload :RailsCommon, 'labkit/tracing/rails/rails_common'
- end
-
- module Sidekiq
- autoload :ClientMiddleware, 'labkit/tracing/sidekiq/client_middleware'
- autoload :ServerMiddleware, 'labkit/tracing/sidekiq/server_middleware'
- autoload :SidekiqCommon, 'labkit/tracing/sidekiq/sidekiq_common'
- end
-
- # 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.
+ # Tracing is only enabled when the `GITLAB_TRACING` env var is configured.
def self.enabled?
connection_string.present?
end
def self.connection_string
- ENV['GITLAB_TRACING']
+ ENV["GITLAB_TRACING"]
end
def self.tracing_url_template
- ENV['GITLAB_TRACING_URL']
+ ENV["GITLAB_TRACING_URL"]
end
def self.tracing_url_enabled?
enabled? && tracing_url_template.present?
end
@@ -49,9 +37,11 @@
correlation_id = Labkit::Correlation::CorrelationId.current_id.to_s
# Avoid using `format` since it can throw TypeErrors
# which we want to avoid on unsanitised env var input
- tracing_url_template.to_s.gsub('{{ correlation_id }}', correlation_id).gsub('{{ service }}', service_name)
+ tracing_url_template.to_s
+ .gsub("{{ correlation_id }}", correlation_id)
+ .gsub("{{ service }}", service_name)
end
end
end