Module: OpenTelemetry::Propagator::XRay::IDGenerator

Extended by:
IDGenerator
Included in:
IDGenerator
Defined in:
lib/opentelemetry/propagator/xray/id_generator.rb

Overview

This module is intended to only be used as an override for how to generate IDs to be compliant with XRay

Instance Method Summary collapse

Instance Method Details

#generate_span_idbytes

Generates a valid span identifier, an 8-byte string with at least one non-zero byte.

Returns:

  • (bytes)

    a valid span ID.



31
32
33
# File 'lib/opentelemetry/propagator/xray/id_generator.rb', line 31

def generate_span_id
  OpenTelemetry::Trace.generate_span_id
end

#generate_trace_idbytes

Generates a valid trace identifier, a 16-byte string with at least one non-zero byte. AWS Docs: https://docs.aws.amazon.com/xray/latest/api/API_PutTraceSegments.html hi - 4 bytes timestamp, 4 bytes random (Mid) low - 8 bytes random. Since we include timestamp, impossible to be invalid.

Returns:

  • (bytes)

    a valid trace ID that is compliant with AWS XRay.



21
22
23
24
25
# File 'lib/opentelemetry/propagator/xray/id_generator.rb', line 21

def generate_trace_id
  time_hi = generate_time_bytes
  mid_and_low = Random.bytes(12)
  time_hi << mid_and_low
end