lib/labkit/tracing.rb in gitlab-labkit-0.0.4 vs lib/labkit/tracing.rb in gitlab-labkit-0.0.5
- old
+ new
@@ -9,12 +9,12 @@
autoload :GRPCInterceptor, 'labkit/tracing/grpc_interceptor'
autoload :JaegerFactory, 'labkit/tracing/jaeger_factory'
autoload :RackMiddleware, 'labkit/tracing/rack_middleware'
module Rails
- autoload :ActionViewSubscriber, 'labkit/tracing/rails/action_view_subscriber.rb'
- autoload :ActiveRecordSubscriber, 'labkit/tracing/rails/active_record_subscriber.rb'
+ 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'
@@ -45,9 +45,13 @@
# This will provide a link into the distributed tracing for the current trace,
# if it has been captured.
def self.tracing_url(service_name)
return unless tracing_url_enabled?
- format(tracing_url_template.to_s, { correlation_id: Labkit::Correlation::CorrelationId.current_id.to_s, service: service_name })
+ 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)
end
end
end