Module: Foam::Otel::Vendor::Datadog

Defined in:
lib/foam/otel/vendor/datadog.rb

Overview

Datadog coexistence (contract SPEC.md section 7.3): correlation-only. Foam never parents from, mutates, or patches the DD tracer — it reads DD's correlation ids VERBATIM (no format conversion; DD ids are 64/128-bit numerics, not W3C hex) and attaches them to foam spans and log records so one record cross-links both backends. No active DD trace -> nil, and the attributes are simply absent (never fabricated).

Class Method Summary collapse

Class Method Details

.correlation_attributesObject

-> { "dd.trace_id" => ..., "dd.span_id" => ... } or nil. Never raises.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/foam/otel/vendor/datadog.rb', line 16

def correlation_attributes
  return nil unless defined?(::Datadog::Tracing)

  correlation = ::Datadog::Tracing.correlation
  return nil if correlation.nil?

  trace_id = correlation.trace_id
  span_id = correlation.span_id
  return nil if trace_id.nil? || trace_id.to_s == "0" || trace_id == 0

  attrs = { "dd.trace_id" => trace_id.to_s }
  attrs["dd.span_id"] = span_id.to_s unless span_id.nil? || span_id == 0
  attrs
rescue StandardError
  nil
end