[BREAKING CHANGE] Remove AsHexString suffix from ids getters. (#2684)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
This commit is contained in:
		
							parent
							
								
									d71db8cbea
								
							
						
					
					
						commit
						88e760d01c
					
				| 
						 | 
				
			
			@ -65,33 +65,33 @@ public interface SpanContext {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Returns the trace identifier associated with this {@code SpanContext}.
 | 
			
		||||
   * Returns the trace identifier associated with this {@link SpanContext} as lowercase hex.
 | 
			
		||||
   *
 | 
			
		||||
   * @return the trace identifier associated with this {@code SpanContext}.
 | 
			
		||||
   * @return the trace identifier associated with this {@link SpanContext} as lowercase hex.
 | 
			
		||||
   */
 | 
			
		||||
  String getTraceIdAsHexString();
 | 
			
		||||
  String getTraceId();
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Returns the byte[] representation of the trace identifier associated with this {@link
 | 
			
		||||
   * Returns the {@code byte[]} representation of the trace identifier associated with this {@link
 | 
			
		||||
   * SpanContext}.
 | 
			
		||||
   */
 | 
			
		||||
  default byte[] getTraceIdBytes() {
 | 
			
		||||
    return TraceId.bytesFromHex(getTraceIdAsHexString());
 | 
			
		||||
    return TraceId.bytesFromHex(getTraceId());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Returns the span identifier associated with this {@code SpanContext}.
 | 
			
		||||
   * Returns the span identifier associated with this {@link SpanContext} as lowercase hex.
 | 
			
		||||
   *
 | 
			
		||||
   * @return the span identifier associated with this {@code SpanContext}.
 | 
			
		||||
   * @return the span identifier associated with this {@link SpanContext} as lowercase hex.
 | 
			
		||||
   */
 | 
			
		||||
  String getSpanIdAsHexString();
 | 
			
		||||
  String getSpanId();
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Returns the byte[] representation of the span identifier associated with this {@link
 | 
			
		||||
   * Returns the {@code byte[]} representation of the span identifier associated with this {@link
 | 
			
		||||
   * SpanContext}.
 | 
			
		||||
   */
 | 
			
		||||
  default byte[] getSpanIdBytes() {
 | 
			
		||||
    return SpanId.bytesFromHex(getSpanIdAsHexString());
 | 
			
		||||
    return SpanId.bytesFromHex(getSpanId());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /** Whether the span in this context is sampled. */
 | 
			
		||||
| 
						 | 
				
			
			@ -119,7 +119,7 @@ public interface SpanContext {
 | 
			
		|||
   * @return {@code true} if this {@code SpanContext} is valid.
 | 
			
		||||
   */
 | 
			
		||||
  default boolean isValid() {
 | 
			
		||||
    return TraceId.isValid(getTraceIdAsHexString()) && SpanId.isValid(getSpanIdAsHexString());
 | 
			
		||||
    return TraceId.isValid(getTraceId()) && SpanId.isValid(getSpanId());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -112,14 +112,14 @@ public final class W3CTraceContextPropagator implements TextMapPropagator {
 | 
			
		|||
    chars[1] = VERSION.charAt(1);
 | 
			
		||||
    chars[2] = TRACEPARENT_DELIMITER;
 | 
			
		||||
 | 
			
		||||
    String traceId = spanContext.getTraceIdAsHexString();
 | 
			
		||||
    String traceId = spanContext.getTraceId();
 | 
			
		||||
    for (int i = 0; i < traceId.length(); i++) {
 | 
			
		||||
      chars[TRACE_ID_OFFSET + i] = traceId.charAt(i);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    chars[SPAN_ID_OFFSET - 1] = TRACEPARENT_DELIMITER;
 | 
			
		||||
 | 
			
		||||
    String spanId = spanContext.getSpanIdAsHexString();
 | 
			
		||||
    String spanId = spanContext.getSpanId();
 | 
			
		||||
    for (int i = 0; i < spanId.length(); i++) {
 | 
			
		||||
      chars[SPAN_ID_OFFSET + i] = spanId.charAt(i);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -176,8 +176,8 @@ public final class W3CTraceContextPropagator implements TextMapPropagator {
 | 
			
		|||
    try {
 | 
			
		||||
      TraceState traceState = extractTraceState(traceStateHeader);
 | 
			
		||||
      return SpanContext.createFromRemoteParent(
 | 
			
		||||
          contextFromParentHeader.getTraceIdAsHexString(),
 | 
			
		||||
          contextFromParentHeader.getSpanIdAsHexString(),
 | 
			
		||||
          contextFromParentHeader.getTraceId(),
 | 
			
		||||
          contextFromParentHeader.getSpanId(),
 | 
			
		||||
          contextFromParentHeader.getTraceFlags(),
 | 
			
		||||
          traceState);
 | 
			
		||||
    } catch (IllegalArgumentException e) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,8 +31,8 @@ class SpanContextTest {
 | 
			
		|||
 | 
			
		||||
  @Test
 | 
			
		||||
  void invalidSpanContext() {
 | 
			
		||||
    assertThat(SpanContext.getInvalid().getTraceIdAsHexString()).isEqualTo(TraceId.getInvalid());
 | 
			
		||||
    assertThat(SpanContext.getInvalid().getSpanIdAsHexString()).isEqualTo(SpanId.getInvalid());
 | 
			
		||||
    assertThat(SpanContext.getInvalid().getTraceId()).isEqualTo(TraceId.getInvalid());
 | 
			
		||||
    assertThat(SpanContext.getInvalid().getSpanId()).isEqualTo(SpanId.getInvalid());
 | 
			
		||||
    assertThat(SpanContext.getInvalid().getTraceFlags()).isEqualTo(TraceFlags.getDefault());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -55,14 +55,14 @@ class SpanContextTest {
 | 
			
		|||
 | 
			
		||||
  @Test
 | 
			
		||||
  void getTraceId() {
 | 
			
		||||
    assertThat(first.getTraceIdAsHexString()).isEqualTo(FIRST_TRACE_ID);
 | 
			
		||||
    assertThat(second.getTraceIdAsHexString()).isEqualTo(SECOND_TRACE_ID);
 | 
			
		||||
    assertThat(first.getTraceId()).isEqualTo(FIRST_TRACE_ID);
 | 
			
		||||
    assertThat(second.getTraceId()).isEqualTo(SECOND_TRACE_ID);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  void getSpanId() {
 | 
			
		||||
    assertThat(first.getSpanIdAsHexString()).isEqualTo(FIRST_SPAN_ID);
 | 
			
		||||
    assertThat(second.getSpanIdAsHexString()).isEqualTo(SECOND_SPAN_ID);
 | 
			
		||||
    assertThat(first.getSpanId()).isEqualTo(FIRST_SPAN_ID);
 | 
			
		||||
    assertThat(second.getSpanId()).isEqualTo(SECOND_SPAN_ID);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -232,8 +232,8 @@ final class Adapter {
 | 
			
		|||
    // https://github.com/open-telemetry/opentelemetry-java/pull/481/files#r312577862
 | 
			
		||||
    return new SpanRef(
 | 
			
		||||
        SpanRefType.FOLLOWS_FROM,
 | 
			
		||||
        TraceId.traceIdLowBytesAsLong(link.getSpanContext().getTraceIdAsHexString()),
 | 
			
		||||
        TraceId.traceIdHighBytesAsLong(link.getSpanContext().getTraceIdAsHexString()),
 | 
			
		||||
        SpanId.asLong(link.getSpanContext().getSpanIdAsHexString()));
 | 
			
		||||
        TraceId.traceIdLowBytesAsLong(link.getSpanContext().getTraceId()),
 | 
			
		||||
        TraceId.traceIdHighBytesAsLong(link.getSpanContext().getTraceId()),
 | 
			
		||||
        SpanId.asLong(link.getSpanContext().getSpanId()));
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -90,14 +90,14 @@ public final class AwsXrayPropagator implements TextMapPropagator {
 | 
			
		|||
 | 
			
		||||
    SpanContext spanContext = span.getSpanContext();
 | 
			
		||||
 | 
			
		||||
    String otTraceId = spanContext.getTraceIdAsHexString();
 | 
			
		||||
    String otTraceId = spanContext.getTraceId();
 | 
			
		||||
    String xrayTraceId =
 | 
			
		||||
        TRACE_ID_VERSION
 | 
			
		||||
            + TRACE_ID_DELIMITER
 | 
			
		||||
            + otTraceId.substring(0, TRACE_ID_FIRST_PART_LENGTH)
 | 
			
		||||
            + TRACE_ID_DELIMITER
 | 
			
		||||
            + otTraceId.substring(TRACE_ID_FIRST_PART_LENGTH);
 | 
			
		||||
    String parentId = spanContext.getSpanIdAsHexString();
 | 
			
		||||
    String parentId = spanContext.getSpanId();
 | 
			
		||||
    char samplingFlag = spanContext.isSampled() ? IS_SAMPLED : NOT_SAMPLED;
 | 
			
		||||
    // TODO: Add OT trace state to the X-Ray trace header
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,8 +31,8 @@ final class B3PropagatorInjectorMultipleHeaders implements B3PropagatorInjector
 | 
			
		|||
      sampled = Common.TRUE_INT;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    setter.set(carrier, B3Propagator.TRACE_ID_HEADER, spanContext.getTraceIdAsHexString());
 | 
			
		||||
    setter.set(carrier, B3Propagator.SPAN_ID_HEADER, spanContext.getSpanIdAsHexString());
 | 
			
		||||
    setter.set(carrier, B3Propagator.TRACE_ID_HEADER, spanContext.getTraceId());
 | 
			
		||||
    setter.set(carrier, B3Propagator.SPAN_ID_HEADER, spanContext.getSpanId());
 | 
			
		||||
    setter.set(carrier, B3Propagator.SAMPLED_HEADER, sampled);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,11 +36,11 @@ final class B3PropagatorInjectorSingleHeader implements B3PropagatorInjector {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    char[] chars = new char[COMBINED_HEADER_SIZE];
 | 
			
		||||
    String traceId = spanContext.getTraceIdAsHexString();
 | 
			
		||||
    String traceId = spanContext.getTraceId();
 | 
			
		||||
    traceId.getChars(0, traceId.length(), chars, 0);
 | 
			
		||||
    chars[SPAN_ID_OFFSET - 1] = B3Propagator.COMBINED_HEADER_DELIMITER_CHAR;
 | 
			
		||||
 | 
			
		||||
    String spanId = spanContext.getSpanIdAsHexString();
 | 
			
		||||
    String spanId = spanContext.getSpanId();
 | 
			
		||||
    System.arraycopy(spanId.toCharArray(), 0, chars, SPAN_ID_OFFSET, SpanId.getHexLength());
 | 
			
		||||
 | 
			
		||||
    chars[SAMPLED_FLAG_OFFSET - 1] = B3Propagator.COMBINED_HEADER_DELIMITER_CHAR;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -99,13 +99,13 @@ public final class JaegerPropagator implements TextMapPropagator {
 | 
			
		|||
 | 
			
		||||
    char[] chars = new char[PROPAGATION_HEADER_SIZE];
 | 
			
		||||
 | 
			
		||||
    String traceId = spanContext.getTraceIdAsHexString();
 | 
			
		||||
    String traceId = spanContext.getTraceId();
 | 
			
		||||
    for (int i = 0; i < traceId.length(); i++) {
 | 
			
		||||
      chars[i] = traceId.charAt(i);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    chars[SPAN_ID_OFFSET - 1] = PROPAGATION_HEADER_DELIMITER;
 | 
			
		||||
    String spanId = spanContext.getSpanIdAsHexString();
 | 
			
		||||
    String spanId = spanContext.getSpanId();
 | 
			
		||||
    for (int i = 0; i < spanId.length(); i++) {
 | 
			
		||||
      chars[SPAN_ID_OFFSET + i] = spanId.charAt(i);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -64,10 +64,8 @@ public final class OtTracerPropagator implements TextMapPropagator {
 | 
			
		|||
    // Lightstep trace id MUST be 64-bits therefore OpenTelemetry trace id is truncated to 64-bits
 | 
			
		||||
    // by retaining least significant (right-most) bits.
 | 
			
		||||
    setter.set(
 | 
			
		||||
        carrier,
 | 
			
		||||
        TRACE_ID_HEADER,
 | 
			
		||||
        spanContext.getTraceIdAsHexString().substring(TraceId.getHexLength() / 2));
 | 
			
		||||
    setter.set(carrier, SPAN_ID_HEADER, spanContext.getSpanIdAsHexString());
 | 
			
		||||
        carrier, TRACE_ID_HEADER, spanContext.getTraceId().substring(TraceId.getHexLength() / 2));
 | 
			
		||||
    setter.set(carrier, SPAN_ID_HEADER, spanContext.getSpanId());
 | 
			
		||||
    setter.set(carrier, SAMPLED_HEADER, String.valueOf(spanContext.isSampled()));
 | 
			
		||||
 | 
			
		||||
    // Baggage is only injected if there is a valid SpanContext
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -50,8 +50,8 @@ class SpanConverter {
 | 
			
		|||
 | 
			
		||||
  static SpanContext mapSpanContext(io.opentelemetry.api.trace.SpanContext otelSpanContext) {
 | 
			
		||||
    return SpanContext.create(
 | 
			
		||||
        TraceId.fromLowerBase16(otelSpanContext.getTraceIdAsHexString()),
 | 
			
		||||
        SpanId.fromLowerBase16(otelSpanContext.getSpanIdAsHexString()),
 | 
			
		||||
        TraceId.fromLowerBase16(otelSpanContext.getTraceId()),
 | 
			
		||||
        SpanId.fromLowerBase16(otelSpanContext.getSpanId()),
 | 
			
		||||
        TraceOptions.builder().setIsSampled(otelSpanContext.isSampled()).build(),
 | 
			
		||||
        mapTracestate(otelSpanContext.getTraceState()));
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -170,7 +170,7 @@ class InteroperabilityTest {
 | 
			
		|||
    assertThat(export1.size()).isEqualTo(1);
 | 
			
		||||
    SpanData spanData1 = export1.iterator().next();
 | 
			
		||||
    assertThat(spanData1.getName()).isEqualTo("OpenCensusSpan");
 | 
			
		||||
    assertThat(spanData1.getLinks().get(0).getSpanContext().getSpanIdAsHexString())
 | 
			
		||||
    assertThat(spanData1.getLinks().get(0).getSpanContext().getSpanId())
 | 
			
		||||
        .isEqualTo(remoteParentSpan.getContext().getSpanId().toLowerBase16());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -237,7 +237,7 @@ class InteroperabilityTest {
 | 
			
		|||
    assertThat(export3.size()).isEqualTo(1);
 | 
			
		||||
    SpanData spanData3 = export3.iterator().next();
 | 
			
		||||
    assertThat(spanData3.getName()).isEqualTo("OpenCensusSpan");
 | 
			
		||||
    assertThat(spanData3.getLinks().get(0).getSpanContext().getSpanIdAsHexString())
 | 
			
		||||
    assertThat(spanData3.getLinks().get(0).getSpanContext().getSpanId())
 | 
			
		||||
        .isEqualTo(parentLinkSpan.getContext().getSpanId().toLowerBase16());
 | 
			
		||||
    assertThat(spanData3.getKind()).isEqualTo(SpanKind.SERVER);
 | 
			
		||||
    assertThat(spanData3.getStatus()).isEqualTo(StatusData.ok());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -60,12 +60,12 @@ final class SpanContextShim extends BaseShimObject implements SpanContext {
 | 
			
		|||
 | 
			
		||||
  @Override
 | 
			
		||||
  public String toTraceId() {
 | 
			
		||||
    return context.getTraceIdAsHexString();
 | 
			
		||||
    return context.getTraceId();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  public String toSpanId() {
 | 
			
		||||
    return context.getSpanIdAsHexString();
 | 
			
		||||
    return context.getSpanId();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,10 +43,8 @@ class SpanShimTest {
 | 
			
		|||
    SpanContextShim contextShim = (SpanContextShim) spanShim.context();
 | 
			
		||||
    assertThat(contextShim).isNotNull();
 | 
			
		||||
    assertThat(span.getSpanContext()).isEqualTo(contextShim.getSpanContext());
 | 
			
		||||
    assertThat(span.getSpanContext().getTraceIdAsHexString().toString())
 | 
			
		||||
        .isEqualTo(contextShim.toTraceId());
 | 
			
		||||
    assertThat(span.getSpanContext().getSpanIdAsHexString().toString())
 | 
			
		||||
        .isEqualTo(contextShim.toSpanId());
 | 
			
		||||
    assertThat(span.getSpanContext().getTraceId().toString()).isEqualTo(contextShim.toTraceId());
 | 
			
		||||
    assertThat(span.getSpanContext().getSpanId().toString()).isEqualTo(contextShim.toSpanId());
 | 
			
		||||
    assertThat(contextShim.baggageItems().iterator().hasNext()).isFalse();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,8 +24,8 @@ class ScopeEvent extends Event {
 | 
			
		|||
  private final String spanId;
 | 
			
		||||
 | 
			
		||||
  ScopeEvent(SpanContext spanContext) {
 | 
			
		||||
    this.traceId = spanContext.getTraceIdAsHexString();
 | 
			
		||||
    this.spanId = spanContext.getSpanIdAsHexString();
 | 
			
		||||
    this.traceId = spanContext.getTraceId();
 | 
			
		||||
    this.spanId = spanContext.getSpanId();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Label("Trace Id")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -73,8 +73,8 @@ class JfrSpanProcessorTest {
 | 
			
		|||
      events.stream()
 | 
			
		||||
          .forEach(
 | 
			
		||||
              e -> {
 | 
			
		||||
                assertEquals(span.getSpanContext().getTraceIdAsHexString(), e.getValue("traceId"));
 | 
			
		||||
                assertEquals(span.getSpanContext().getSpanIdAsHexString(), e.getValue("spanId"));
 | 
			
		||||
                assertEquals(span.getSpanContext().getTraceId(), e.getValue("traceId"));
 | 
			
		||||
                assertEquals(span.getSpanContext().getSpanId(), e.getValue("spanId"));
 | 
			
		||||
                assertEquals(OPERATION_NAME, e.getValue("operationName"));
 | 
			
		||||
              });
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -113,8 +113,8 @@ class JfrSpanProcessorTest {
 | 
			
		|||
      events.stream()
 | 
			
		||||
          .forEach(
 | 
			
		||||
              e -> {
 | 
			
		||||
                assertEquals(span.getSpanContext().getTraceIdAsHexString(), e.getValue("traceId"));
 | 
			
		||||
                assertEquals(span.getSpanContext().getSpanIdAsHexString(), e.getValue("spanId"));
 | 
			
		||||
                assertEquals(span.getSpanContext().getTraceId(), e.getValue("traceId"));
 | 
			
		||||
                assertEquals(span.getSpanContext().getSpanId(), e.getValue("spanId"));
 | 
			
		||||
                if ("Span".equals(e.getEventType().getLabel())) {
 | 
			
		||||
                  assertEquals(OPERATION_NAME, e.getValue("operationName"));
 | 
			
		||||
                }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,7 +37,7 @@ final class TracezSpanProcessor implements SpanProcessor {
 | 
			
		|||
 | 
			
		||||
  @Override
 | 
			
		||||
  public void onStart(Context parentContext, ReadWriteSpan span) {
 | 
			
		||||
    runningSpanCache.put(span.getSpanContext().getSpanIdAsHexString(), span);
 | 
			
		||||
    runningSpanCache.put(span.getSpanContext().getSpanId(), span);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
| 
						 | 
				
			
			@ -47,7 +47,7 @@ final class TracezSpanProcessor implements SpanProcessor {
 | 
			
		|||
 | 
			
		||||
  @Override
 | 
			
		||||
  public void onEnd(ReadableSpan span) {
 | 
			
		||||
    runningSpanCache.remove(span.getSpanContext().getSpanIdAsHexString());
 | 
			
		||||
    runningSpanCache.remove(span.getSpanContext().getSpanId());
 | 
			
		||||
    if (!sampled || span.getSpanContext().isSampled()) {
 | 
			
		||||
      completedSpanCache.putIfAbsent(span.getName(), new TracezSpanBuckets());
 | 
			
		||||
      completedSpanCache.get(span.getName()).addToBucket(span);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -270,8 +270,8 @@ class TracezZPageHandlerTest {
 | 
			
		|||
    assertThat(output.toString()).contains("<h2>Span Details</h2>");
 | 
			
		||||
    assertThat(output.toString()).contains("<b> Span Name: " + RUNNING_SPAN + "</b>");
 | 
			
		||||
    assertThat(output.toString()).contains("<b> Number of running: 1");
 | 
			
		||||
    assertThat(output.toString()).contains(runningSpan.getSpanContext().getTraceIdAsHexString());
 | 
			
		||||
    assertThat(output.toString()).contains(runningSpan.getSpanContext().getSpanIdAsHexString());
 | 
			
		||||
    assertThat(output.toString()).contains(runningSpan.getSpanContext().getTraceId());
 | 
			
		||||
    assertThat(output.toString()).contains(runningSpan.getSpanContext().getSpanId());
 | 
			
		||||
 | 
			
		||||
    runningSpan.end();
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -294,10 +294,10 @@ class TracezZPageHandlerTest {
 | 
			
		|||
    assertThat(output.toString()).contains("<h2>Span Details</h2>");
 | 
			
		||||
    assertThat(output.toString()).contains("<b> Span Name: " + LATENCY_SPAN + "</b>");
 | 
			
		||||
    assertThat(output.toString()).contains("<b> Number of latency samples: 2");
 | 
			
		||||
    assertThat(output.toString()).contains(latencySpan1.getSpanContext().getTraceIdAsHexString());
 | 
			
		||||
    assertThat(output.toString()).contains(latencySpan1.getSpanContext().getSpanIdAsHexString());
 | 
			
		||||
    assertThat(output.toString()).contains(latencySpan2.getSpanContext().getTraceIdAsHexString());
 | 
			
		||||
    assertThat(output.toString()).contains(latencySpan2.getSpanContext().getSpanIdAsHexString());
 | 
			
		||||
    assertThat(output.toString()).contains(latencySpan1.getSpanContext().getTraceId());
 | 
			
		||||
    assertThat(output.toString()).contains(latencySpan1.getSpanContext().getSpanId());
 | 
			
		||||
    assertThat(output.toString()).contains(latencySpan2.getSpanContext().getTraceId());
 | 
			
		||||
    assertThat(output.toString()).contains(latencySpan2.getSpanContext().getSpanId());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
| 
						 | 
				
			
			@ -318,10 +318,10 @@ class TracezZPageHandlerTest {
 | 
			
		|||
    assertThat(output.toString()).contains("<h2>Span Details</h2>");
 | 
			
		||||
    assertThat(output.toString()).contains("<b> Span Name: " + ERROR_SPAN + "</b>");
 | 
			
		||||
    assertThat(output.toString()).contains("<b> Number of error samples: 2");
 | 
			
		||||
    assertThat(output.toString()).contains(errorSpan1.getSpanContext().getTraceIdAsHexString());
 | 
			
		||||
    assertThat(output.toString()).contains(errorSpan1.getSpanContext().getSpanIdAsHexString());
 | 
			
		||||
    assertThat(output.toString()).contains(errorSpan2.getSpanContext().getTraceIdAsHexString());
 | 
			
		||||
    assertThat(output.toString()).contains(errorSpan2.getSpanContext().getSpanIdAsHexString());
 | 
			
		||||
    assertThat(output.toString()).contains(errorSpan1.getSpanContext().getTraceId());
 | 
			
		||||
    assertThat(output.toString()).contains(errorSpan1.getSpanContext().getSpanId());
 | 
			
		||||
    assertThat(output.toString()).contains(errorSpan2.getSpanContext().getTraceId());
 | 
			
		||||
    assertThat(output.toString()).contains(errorSpan2.getSpanContext().getSpanId());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -515,9 +515,9 @@ final class RecordEventsReadableSpan implements ReadWriteSpan {
 | 
			
		|||
    }
 | 
			
		||||
    StringBuilder sb = new StringBuilder();
 | 
			
		||||
    sb.append("RecordEventsReadableSpan{traceId=");
 | 
			
		||||
    sb.append(context.getTraceIdAsHexString());
 | 
			
		||||
    sb.append(context.getTraceId());
 | 
			
		||||
    sb.append(", spanId=");
 | 
			
		||||
    sb.append(context.getSpanIdAsHexString());
 | 
			
		||||
    sb.append(context.getSpanId());
 | 
			
		||||
    sb.append(", parentSpanContext=");
 | 
			
		||||
    sb.append(parentSpanContext);
 | 
			
		||||
    sb.append(", name=");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -175,7 +175,7 @@ final class SdkSpanBuilder implements SpanBuilder {
 | 
			
		|||
      traceId = idGenerator.generateTraceId();
 | 
			
		||||
    } else {
 | 
			
		||||
      // New child span.
 | 
			
		||||
      traceId = parentSpanContext.getTraceIdAsHexString();
 | 
			
		||||
      traceId = parentSpanContext.getTraceId();
 | 
			
		||||
    }
 | 
			
		||||
    List<LinkData> immutableLinks =
 | 
			
		||||
        links == null ? Collections.emptyList() : Collections.unmodifiableList(links);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,7 +31,7 @@ public interface SpanData {
 | 
			
		|||
   * @return the trace id.
 | 
			
		||||
   */
 | 
			
		||||
  default String getTraceId() {
 | 
			
		||||
    return getSpanContext().getTraceIdAsHexString();
 | 
			
		||||
    return getSpanContext().getTraceId();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
| 
						 | 
				
			
			@ -40,7 +40,7 @@ public interface SpanData {
 | 
			
		|||
   * @return the span id.
 | 
			
		||||
   */
 | 
			
		||||
  default String getSpanId() {
 | 
			
		||||
    return getSpanContext().getSpanIdAsHexString();
 | 
			
		||||
    return getSpanContext().getSpanId();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /** Whether the 'sampled' option set on this span. */
 | 
			
		||||
| 
						 | 
				
			
			@ -70,7 +70,7 @@ public interface SpanData {
 | 
			
		|||
   * @return the parent {@code SpanId} or an invalid SpanId if this is a root {@code Span}.
 | 
			
		||||
   */
 | 
			
		||||
  default String getParentSpanId() {
 | 
			
		||||
    return getParentSpanContext().getSpanIdAsHexString();
 | 
			
		||||
    return getParentSpanContext().getSpanId();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -633,8 +633,8 @@ class SdkSpanBuilderTest {
 | 
			
		|||
    try (Scope ignored = parent.makeCurrent()) {
 | 
			
		||||
      Span span = sdkTracer.spanBuilder(SPAN_NAME).setNoParent().startSpan();
 | 
			
		||||
      try {
 | 
			
		||||
        assertThat(span.getSpanContext().getTraceIdAsHexString())
 | 
			
		||||
            .isNotEqualTo(parent.getSpanContext().getTraceIdAsHexString());
 | 
			
		||||
        assertThat(span.getSpanContext().getTraceId())
 | 
			
		||||
            .isNotEqualTo(parent.getSpanContext().getTraceId());
 | 
			
		||||
        Mockito.verify(mockedSpanProcessor)
 | 
			
		||||
            .onStart(Mockito.same(Context.root()), Mockito.same((ReadWriteSpan) span));
 | 
			
		||||
        Span spanNoParent =
 | 
			
		||||
| 
						 | 
				
			
			@ -645,8 +645,8 @@ class SdkSpanBuilderTest {
 | 
			
		|||
                .setNoParent()
 | 
			
		||||
                .startSpan();
 | 
			
		||||
        try {
 | 
			
		||||
          assertThat(span.getSpanContext().getTraceIdAsHexString())
 | 
			
		||||
              .isNotEqualTo(parent.getSpanContext().getTraceIdAsHexString());
 | 
			
		||||
          assertThat(span.getSpanContext().getTraceId())
 | 
			
		||||
              .isNotEqualTo(parent.getSpanContext().getTraceId());
 | 
			
		||||
          Mockito.verify(mockedSpanProcessor)
 | 
			
		||||
              .onStart(Mockito.same(Context.root()), Mockito.same((ReadWriteSpan) spanNoParent));
 | 
			
		||||
        } finally {
 | 
			
		||||
| 
						 | 
				
			
			@ -671,10 +671,10 @@ class SdkSpanBuilderTest {
 | 
			
		|||
      try {
 | 
			
		||||
        Mockito.verify(mockedSpanProcessor)
 | 
			
		||||
            .onStart(Mockito.same(parentContext), Mockito.same((ReadWriteSpan) span));
 | 
			
		||||
        assertThat(span.getSpanContext().getTraceIdAsHexString())
 | 
			
		||||
            .isEqualTo(parent.getSpanContext().getTraceIdAsHexString());
 | 
			
		||||
        assertThat(span.getSpanContext().getTraceId())
 | 
			
		||||
            .isEqualTo(parent.getSpanContext().getTraceId());
 | 
			
		||||
        assertThat(span.toSpanData().getParentSpanId())
 | 
			
		||||
            .isEqualTo(parent.getSpanContext().getSpanIdAsHexString());
 | 
			
		||||
            .isEqualTo(parent.getSpanContext().getSpanId());
 | 
			
		||||
 | 
			
		||||
        final Context parentContext2 = Context.current().with(parent);
 | 
			
		||||
        RecordEventsReadableSpan span2 =
 | 
			
		||||
| 
						 | 
				
			
			@ -687,8 +687,8 @@ class SdkSpanBuilderTest {
 | 
			
		|||
        try {
 | 
			
		||||
          Mockito.verify(mockedSpanProcessor)
 | 
			
		||||
              .onStart(Mockito.same(parentContext2), Mockito.same((ReadWriteSpan) span2));
 | 
			
		||||
          assertThat(span2.getSpanContext().getTraceIdAsHexString())
 | 
			
		||||
              .isEqualTo(parent.getSpanContext().getTraceIdAsHexString());
 | 
			
		||||
          assertThat(span2.getSpanContext().getTraceId())
 | 
			
		||||
              .isEqualTo(parent.getSpanContext().getTraceId());
 | 
			
		||||
        } finally {
 | 
			
		||||
          span2.end();
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -712,10 +712,10 @@ class SdkSpanBuilderTest {
 | 
			
		|||
      try {
 | 
			
		||||
        Mockito.verify(mockedSpanProcessor)
 | 
			
		||||
            .onStart(Mockito.same(parentContext), Mockito.same((ReadWriteSpan) span));
 | 
			
		||||
        assertThat(span.getSpanContext().getTraceIdAsHexString())
 | 
			
		||||
            .isEqualTo(parent.getSpanContext().getTraceIdAsHexString());
 | 
			
		||||
        assertThat(span.getSpanContext().getTraceId())
 | 
			
		||||
            .isEqualTo(parent.getSpanContext().getTraceId());
 | 
			
		||||
        assertThat(span.toSpanData().getParentSpanId())
 | 
			
		||||
            .isEqualTo(parent.getSpanContext().getSpanIdAsHexString());
 | 
			
		||||
            .isEqualTo(parent.getSpanContext().getSpanId());
 | 
			
		||||
      } finally {
 | 
			
		||||
        span.end();
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			@ -735,10 +735,10 @@ class SdkSpanBuilderTest {
 | 
			
		|||
      try {
 | 
			
		||||
        Mockito.verify(mockedSpanProcessor)
 | 
			
		||||
            .onStart(Mockito.same(context), Mockito.same((ReadWriteSpan) span));
 | 
			
		||||
        assertThat(span.getSpanContext().getTraceIdAsHexString())
 | 
			
		||||
            .isEqualTo(parent.getSpanContext().getTraceIdAsHexString());
 | 
			
		||||
        assertThat(span.getSpanContext().getTraceId())
 | 
			
		||||
            .isEqualTo(parent.getSpanContext().getTraceId());
 | 
			
		||||
        assertThat(span.toSpanData().getParentSpanId())
 | 
			
		||||
            .isEqualTo(parent.getSpanContext().getSpanIdAsHexString());
 | 
			
		||||
            .isEqualTo(parent.getSpanContext().getSpanId());
 | 
			
		||||
      } finally {
 | 
			
		||||
        span.end();
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			@ -762,10 +762,10 @@ class SdkSpanBuilderTest {
 | 
			
		|||
      try {
 | 
			
		||||
        Mockito.verify(mockedSpanProcessor)
 | 
			
		||||
            .onStart(Mockito.same(emptyContext), Mockito.same((ReadWriteSpan) span));
 | 
			
		||||
        assertThat(span.getSpanContext().getTraceIdAsHexString())
 | 
			
		||||
            .isNotEqualTo(parent.getSpanContext().getTraceIdAsHexString());
 | 
			
		||||
        assertThat(span.getSpanContext().getTraceId())
 | 
			
		||||
            .isNotEqualTo(parent.getSpanContext().getTraceId());
 | 
			
		||||
        assertThat(span.toSpanData().getParentSpanId())
 | 
			
		||||
            .isNotEqualTo(parent.getSpanContext().getSpanIdAsHexString());
 | 
			
		||||
            .isNotEqualTo(parent.getSpanContext().getSpanId());
 | 
			
		||||
      } finally {
 | 
			
		||||
        span.end();
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			@ -784,10 +784,10 @@ class SdkSpanBuilderTest {
 | 
			
		|||
      try {
 | 
			
		||||
        Mockito.verify(mockedSpanProcessor)
 | 
			
		||||
            .onStart(Mockito.same(implicitParent), Mockito.same((ReadWriteSpan) span));
 | 
			
		||||
        assertThat(span.getSpanContext().getTraceIdAsHexString())
 | 
			
		||||
            .isEqualTo(parent.getSpanContext().getTraceIdAsHexString());
 | 
			
		||||
        assertThat(span.getSpanContext().getTraceId())
 | 
			
		||||
            .isEqualTo(parent.getSpanContext().getTraceId());
 | 
			
		||||
        assertThat(span.toSpanData().getParentSpanId())
 | 
			
		||||
            .isEqualTo(parent.getSpanContext().getSpanIdAsHexString());
 | 
			
		||||
            .isEqualTo(parent.getSpanContext().getSpanId());
 | 
			
		||||
      } finally {
 | 
			
		||||
        span.end();
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			@ -808,8 +808,8 @@ class SdkSpanBuilderTest {
 | 
			
		|||
      Mockito.verify(mockedSpanProcessor)
 | 
			
		||||
          .onStart(
 | 
			
		||||
              ArgumentMatchers.same(parentContext), ArgumentMatchers.same((ReadWriteSpan) span));
 | 
			
		||||
      assertThat(span.getSpanContext().getTraceIdAsHexString())
 | 
			
		||||
          .isNotEqualTo(parent.getSpanContext().getTraceIdAsHexString());
 | 
			
		||||
      assertThat(span.getSpanContext().getTraceId())
 | 
			
		||||
          .isNotEqualTo(parent.getSpanContext().getTraceId());
 | 
			
		||||
      assertThat(SpanId.isValid(span.toSpanData().getParentSpanId())).isFalse();
 | 
			
		||||
    } finally {
 | 
			
		||||
      span.end();
 | 
			
		||||
| 
						 | 
				
			
			@ -905,13 +905,13 @@ class SdkSpanBuilderTest {
 | 
			
		|||
    assertThat(span.toSpanData().toString())
 | 
			
		||||
        .matches(
 | 
			
		||||
            "SpanData\\{spanContext=ImmutableSpanContext\\{"
 | 
			
		||||
                + "traceIdAsHexString=[0-9a-f]{32}, "
 | 
			
		||||
                + "spanIdAsHexString=[0-9a-f]{16}, "
 | 
			
		||||
                + "traceId=[0-9a-f]{32}, "
 | 
			
		||||
                + "spanId=[0-9a-f]{16}, "
 | 
			
		||||
                + "traceFlags=1, "
 | 
			
		||||
                + "traceState=ArrayBasedTraceState\\{entries=\\[]}, remote=false}, "
 | 
			
		||||
                + "parentSpanContext=ImmutableSpanContext\\{"
 | 
			
		||||
                + "traceIdAsHexString=00000000000000000000000000000000, "
 | 
			
		||||
                + "spanIdAsHexString=0000000000000000, "
 | 
			
		||||
                + "traceId=00000000000000000000000000000000, "
 | 
			
		||||
                + "spanId=0000000000000000, "
 | 
			
		||||
                + "traceFlags=0, "
 | 
			
		||||
                + "traceState=ArrayBasedTraceState\\{entries=\\[]}, remote=false}, "
 | 
			
		||||
                + "resource=Resource\\{attributes=\\{service.name=\"unknown_service:java\", "
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue