lib/ddtrace/tracer.rb in ddtrace-0.33.1 vs lib/ddtrace/tracer.rb in ddtrace-0.34.0
- old
+ new
@@ -1,10 +1,11 @@
require 'pp'
require 'thread'
require 'logger'
require 'pathname'
+require 'ddtrace/environment'
require 'ddtrace/span'
require 'ddtrace/context'
require 'ddtrace/logger'
require 'ddtrace/writer'
require 'ddtrace/sampler'
@@ -81,11 +82,11 @@
else
Datadog::ContextFlush::Finished.new
end
@mutex = Mutex.new
- @tags = {}
+ @tags = options.fetch(:tags, Datadog.configuration.tags)
# Enable priority sampling by default
activate_priority_sampling!(@sampler)
end
@@ -152,11 +153,12 @@
# appended to each span created by the tracer. Keys and values must be strings.
# A valid example is:
#
# tracer.set_tags('env' => 'prod', 'component' => 'core')
def set_tags(tags)
- @tags.update(tags)
+ string_tags = Hash[tags.collect { |k, v| [k.to_s, v] }]
+ @tags = @tags.merge(string_tags)
end
# Guess context and parent from child_of entry.
def guess_context_and_parent(child_of)
# call_context should not be in this code path, as start_span
@@ -204,12 +206,12 @@
end
else
# child span
span.parent = parent # sets service, trace_id, parent_id, sampled
end
- tags.each { |k, v| span.set_tag(k, v) } unless tags.empty?
@tags.each { |k, v| span.set_tag(k, v) } unless @tags.empty?
+ tags.each { |k, v| span.set_tag(k, v) } unless tags.empty?
span.start_time = start_time
# this could at some point be optional (start_active_span vs start_manual_span)
ctx.add_span(span) unless ctx.nil?
@@ -389,9 +391,17 @@
transport_options[:port] = port unless port.nil?
rebuild_writer = true
end
writer_options[:transport_options] = transport_options
+
+ # ensure any configuration to runtime_metrics statsd client is
+ # passed on when writer gets rebuilt
+ unless writer_options.key?(:runtime_metrics)
+ if @writer && !@writer.runtime_metrics.nil?
+ writer_options[:runtime_metrics] = @writer.runtime_metrics
+ end
+ end
if rebuild_writer || writer
# Make sure old writer is shut down before throwing away.
# Don't want additional threads running...
@writer.stop unless writer.nil?