@Test public void generateId_should_not_generate_duplicate_ids_over_reasonable_number_of_attempts() throws Exception { Set<String> ids = new HashSet<>(); int numAttempts = 1000000; for (int i = 0; i < numAttempts; i++) { ids.add(TraceAndSpanIdGenerator.generateId()); } assertThat(ids.size()).isEqualTo(numAttempts); }
public static String generateId() { return longToUnsignedLowerHexString(generate64BitRandomLong()); }
TraceAndSpanIdGenerator { public static String generateId() { return longToUnsignedLowerHexString(generate64BitRandomLong()); } }
TraceAndSpanIdGenerator { public static String generateId() { return longToUnsignedLowerHexString(generate64BitRandomLong()); } private  TraceAndSpanIdGenerator(); }
TraceAndSpanIdGenerator { public static String generateId() { return longToUnsignedLowerHexString(generate64BitRandomLong()); } private  TraceAndSpanIdGenerator(); static String generateId(); static long generate64BitRandomLong(); static String longToUnsignedLowerHexString(long primitiveLong); static long unsignedLowerHexStringToLong(String hexString); static long unsignedLowerHexStringToLong(String hexString, int index); }
TraceAndSpanIdGenerator { public static String generateId() { return longToUnsignedLowerHexString(generate64BitRandomLong()); } private  TraceAndSpanIdGenerator(); static String generateId(); static long generate64BitRandomLong(); static String longToUnsignedLowerHexString(long primitiveLong); static long unsignedLowerHexStringToLong(String hexString); static long unsignedLowerHexStringToLong(String hexString, int index);  }