Sha256: 98b5134d380cc7bb9e834815534dc7fd5efaa8926d4199e04c9b62659d7492bf

Contents?: true

Size: 795 Bytes

Versions: 1

Compression:

Stored size: 795 Bytes

Contents

# frozen_string_literal: true
# typed: ignore

module Datadog
  module OpenTelemetry
    module SDK
      # Generates Datadog-compatible IDs for OpenTelemetry traces.
      # OpenTelemetry traces already produce Datadog-compatible IDs.
      class IdGenerator
        class << self
          include ::OpenTelemetry::Trace

          # Generates a valid trace identifier, a 16-byte string with at least one
          # non-zero byte.
          #
          # @return [String] a valid trace ID.
          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
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ddtrace-1.9.0 lib/datadog/opentelemetry/sdk/id_generator.rb