lib/ddtrace/tracer.rb in ddtrace-0.22.0 vs lib/ddtrace/tracer.rb in ddtrace-0.23.0

- old
+ new

@@ -18,11 +18,11 @@ # example, a trace can be used to track the entire time spent processing a complicated web request. # Even though the request may require multiple resources and machines to handle the request, all # of these function calls and sub-requests would be encapsulated within a single trace. # rubocop:disable Metrics/ClassLength class Tracer - attr_reader :sampler, :services, :tags, :provider + attr_reader :sampler, :tags, :provider attr_accessor :enabled, :writer attr_writer :default_service ALLOWED_SPAN_OPTIONS = [:service, :resource, :span_type].freeze DEFAULT_ON_ERROR = proc { |span, error| span.set_error(error) unless span.nil? } @@ -65,10 +65,19 @@ # Return if the debug mode is activated or not def self.debug_logging log.level == Logger::DEBUG end + def services + # Only log each deprecation warning once (safeguard against log spam) + Datadog::Patcher.do_once('Tracer#set_service_info') do + Datadog::Tracer.log.warn('services: Usage of Tracer.services has been deprecated') + end + + {} + end + # Shorthand that calls the `shutdown!` method of a registered worker. # It's useful to ensure that the Trace Buffer is properly flushed before # shutting down the application. # # For instance: @@ -108,11 +117,10 @@ @provider ||= Datadog::DefaultContextProvider.new # @provider should never be nil @context_flush = options[:partial_flush] ? Datadog::ContextFlush.new(options) : nil @mutex = Mutex.new - @services = {} @tags = {} end # Updates the current \Tracer instance, so that the tracer can be configured after the # initialization. Available +options+ are: @@ -160,18 +168,20 @@ end # Set the information about the given service. A valid example is: # # tracer.set_service_info('web-application', 'rails', 'web') + # + # set_service_info is deprecated, no service information needs to be tracked def set_service_info(service, app, app_type) - @services[service] = { - 'app' => app, - 'app_type' => app_type - } - - return unless Datadog::Tracer.debug_logging - Datadog::Tracer.log.debug("set_service_info: service: #{service} app: #{app} type: #{app_type}") + # Only log each deprecation warning once (safeguard against log spam) + Datadog::Patcher.do_once('Tracer#set_service_info') do + Datadog::Tracer.log.warn(%( + set_service_info: Usage of set_service_info has been deprecated, + service information no longer needs to be reported to the trace agent. + )) + end end # A default value for service. One should really override this one # for non-root spans which have a parent. However, root spans without # a service would be invalid and rejected. @@ -378,11 +388,10 @@ str = String.new('') PP.pp(trace, str) Datadog::Tracer.log.debug(str) end - @writer.write(trace, @services) - @services = {} + @writer.write(trace) end private :write, :guess_context_and_parent end end