Method: Datadog::OpenTelemetry::SDK::IdGenerator.generate_trace_id

Defined in:
lib/datadog/opentelemetry/sdk/id_generator.rb

.generate_trace_idString

Generates a valid trace identifier, a 16-byte string with at least one non-zero byte.

Returns:

  • (String)

    a valid trace ID.



16
17
18
19
20
21
# File 'lib/datadog/opentelemetry/sdk/id_generator.rb', line 16

def generate_trace_id
  loop do
    id = Random.bytes(8) # DEV: Change to 16 (16*8-byte) when 128-bit trace_id is supported.
    return id unless id == ::OpenTelemetry::Trace::INVALID_SPAN_ID
  end
end