lib/datadog/tracing/correlation.rb in ddtrace-1.9.0 vs lib/datadog/tracing/correlation.rb in ddtrace-1.10.0
- old
+ new
@@ -1,8 +1,8 @@
-# typed: true
-
require_relative '../core'
+require_relative 'utils'
+require_relative 'metadata/ext'
module Datadog
module Tracing
# Contains behavior for managing correlations with tracing
# e.g. Retrieve a correlation to the current trace for logging, etc.
@@ -64,13 +64,25 @@
@log_format ||= begin
attributes = []
attributes << "#{LOG_ATTR_ENV}=#{env}" unless env.nil?
attributes << "#{LOG_ATTR_SERVICE}=#{service}"
attributes << "#{LOG_ATTR_VERSION}=#{version}" unless version.nil?
- attributes << "#{LOG_ATTR_TRACE_ID}=#{trace_id}"
+ attributes << "#{LOG_ATTR_TRACE_ID}=#{logging_trace_id}"
attributes << "#{LOG_ATTR_SPAN_ID}=#{span_id}"
attributes.join(' ')
end
+ end
+
+ private
+
+ def logging_trace_id
+ @logging_trace_id ||=
+ if Datadog.configuration.tracing.trace_id_128_bit_logging_enabled &&
+ !Tracing::Utils::TraceId.to_high_order(@trace_id).zero?
+ Kernel.format('%032x', trace_id)
+ else
+ Tracing::Utils::TraceId.to_low_order(@trace_id)
+ end
end
end
module_function