Class: Datadog::OpenTelemetry::SDK::IdGenerator

Inherits:
Object
  • Object
show all
Extended by:
OpenTelemetry::Trace
Defined in:
lib/datadog/opentelemetry/sdk/id_generator.rb

Overview

Generates Datadog-compatible IDs for OpenTelemetry traces. OpenTelemetry traces already produce Datadog-compatible IDs.

Class Method Summary collapse

Class Method Details

.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