lib/ddtrace/tracer.rb in ddtrace-0.13.0.beta1 vs lib/ddtrace/tracer.rb in ddtrace-0.13.0

- old
+ new

@@ -21,10 +21,12 @@ class Tracer attr_reader :sampler, :services, :tags, :provider attr_accessor :enabled, :writer attr_writer :default_service + ALLOWED_SPAN_OPTIONS = [:service, :resource, :span_type].freeze + # Global, memoized, lazy initialized instance of a logger that is used within the the Datadog # namespace. This logger outputs to +STDOUT+ by default, and is considered thread-safe. def self.log unless defined? @logger @logger = Datadog::Logger.new(STDOUT) @@ -202,15 +204,16 @@ # * +child_of+: a \Span or a \Context instance representing the parent for this span. # * +start_time+: when the span actually starts (defaults to \now) # * +tags+: extra tags which should be added to the span. def start_span(name, options = {}) start_time = options.fetch(:start_time, Time.now.utc) + tags = options.fetch(:tags, {}) opts = options.select do |k, _v| # Filter options, we want no side effects with unexpected args. # Plus, this documents the code (Ruby 2 named args would be better but we're Ruby 1.9 compatible) - [:service, :resource, :span_type].include?(k) + ALLOWED_SPAN_OPTIONS.include?(k) end ctx, parent = guess_context_and_parent(options[:child_of]) opts[:context] = ctx unless ctx.nil?