lib/ddtrace/tracer.rb in ddtrace-0.46.0 vs lib/ddtrace/tracer.rb in ddtrace-0.47.0
- old
+ new
@@ -8,29 +8,32 @@
require 'ddtrace/writer'
require 'ddtrace/runtime/identity'
require 'ddtrace/sampler'
require 'ddtrace/sampling'
require 'ddtrace/correlation'
+require 'ddtrace/utils/only_once'
# \Datadog global namespace that includes all tracing functionality for Tracer and Span classes.
module Datadog
# A \Tracer keeps track of the time spent by an application processing a single operation. For
# 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
+ SERVICES_DEPRECATION_WARN_ONLY_ONCE = Datadog::Utils::OnlyOnce.new
+ SET_SERVICE_INFO_DEPRECATION_WARN_ONLY_ONCE = Datadog::Utils::OnlyOnce.new
+
attr_reader :sampler, :tags, :provider, :context_flush
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? }
def services
- # Only log each deprecation warning once (safeguard against log spam)
- Datadog::Patcher.do_once('Tracer#set_service_info') do
+ SERVICES_DEPRECATION_WARN_ONLY_ONCE.run do
Datadog.logger.warn('services: Usage of Tracer.services has been deprecated')
end
{}
end
@@ -127,11 +130,10 @@
#
# 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)
- # Only log each deprecation warning once (safeguard against log spam)
- Datadog::Patcher.do_once('Tracer#set_service_info') do
+ SET_SERVICE_INFO_DEPRECATION_WARN_ONLY_ONCE.run do
Datadog.logger.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