SpanUniqueIdGenerator { public static String toUnique(Span span) { String id = span.getId(); if (span.clientSpan()) { id = getClientId(span.getId()); } return id; }  static String toUnique(Span span); static String toOriginal(Span span); static String getClientId(String id);  }
@Test public void testToUnique() { String originalId = "064c292e02db027c"; Span span = new Span(null, clientAnnotations()); span.setId(originalId); String uniqueID = SpanUniqueIdGenerator.toUnique(span); Assert.assertEquals(originalId + SpanUniqueIdGenerator.CLIENT_ID_SUFFIX, uniqueID); }
@Test(expected = IllegalStateException.class) public void testIllegalState() { String originalId = "064c292e02db027c22g"; Span span = new Span(null, clientAnnotations()); span.setId(originalId); String uniqueID = SpanUniqueIdGenerator.toUnique(span); span.setId(uniqueID); SpanUniqueIdGenerator.toUnique(span); }