generateSpanId static method

Uint8List generateSpanId()

Generate an 8-byte span ID. Returns bytes which can be formatted as a 16-char hex string.

Implementation

static Uint8List generateSpanId() {
  final bytes = Uint8List(8);

  // Generate random bytes until we get a non-zero ID
  do {
    for (int i = 0; i < bytes.length; i++) {
      bytes[i] = _random.nextInt(256);
    }
  } while (_isZero(bytes));

  return bytes;
}