com.nike.wingtips.Span.getSpanStartTimeEpochMicros()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(201)

本文整理了Java中com.nike.wingtips.Span.getSpanStartTimeEpochMicros()方法的一些代码示例,展示了Span.getSpanStartTimeEpochMicros()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Span.getSpanStartTimeEpochMicros()方法的具体详情如下:
包路径:com.nike.wingtips.Span
类名称:Span
方法名:getSpanStartTimeEpochMicros

Span.getSpanStartTimeEpochMicros介绍

暂无

代码示例

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void fromJson_returns_null_if_startTimeEpochMicros_field_is_missing() {
  // given
  Span validSpan = createFilledOutSpan(true);
  String validJson = SpanParser.convertSpanToJSON(validSpan);
  String invalidJson = validJson.replace(
    String.format(",\"%s\":\"%s\"",
           SpanParser.START_TIME_EPOCH_MICROS_FIELD,
           String.valueOf(validSpan.getSpanStartTimeEpochMicros())
    ),
    ""
  );
  // when
  Span result = SpanParser.fromJSON(invalidJson);
  // then
  assertThat(result).isNull();
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void fromKeyValueString_returns_null_if_startTimeEpochMicros_field_is_missing() {
  // given
  Span validSpan = createFilledOutSpan(true);
  String validKeyValStr = SpanParser.convertSpanToKeyValueFormat(validSpan);
  String invalidKeyValStr = validKeyValStr.replace(
    String.format(",%s=\"%s\"",
           SpanParser.START_TIME_EPOCH_MICROS_FIELD,
           String.valueOf(validSpan.getSpanStartTimeEpochMicros())
    ),
    ""
  );
  // when
  Span result = SpanParser.fromKeyValueString(invalidKeyValStr);
  // then
  assertThat(result).isNull();
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void builder_build_ignores_passed_in_spanStartTimeNanos_if_spanStartTimeEpochMicros_is_null() {
  // given
  Span.Builder builder = Span
    .newBuilder("stuff", SpanPurpose.LOCAL_ONLY)
    .withSpanStartTimeNanos(42L)
    .withSpanStartTimeEpochMicros(null);
  // when
  long beforeNanos = System.nanoTime();
  long beforeEpochMicros = TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis());
  Span span = builder.build();
  long afterNanos = System.nanoTime();
  long afterEpochMicros = TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis());
  // then
  assertThat(span.getSpanStartTimeNanos()).isBetween(beforeNanos, afterNanos);
  assertThat(span.getSpanStartTimeEpochMicros()).isBetween(beforeEpochMicros, afterEpochMicros);
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void public_constructor_works_as_expected_for_completed_span() {
  // when
  Span span = new Span(
    traceId, parentSpanId, spanId, spanName, sampleableForFullyCompleteSpan, userId,
    spanPurposeForFullyCompletedSpan, startTimeEpochMicrosForFullyCompleteSpan,
    startTimeNanosForFullyCompleteSpan, durationNanosForFullyCompletedSpan, tags, annotations
  );
  // then
  assertThat(span.getTraceId()).isEqualTo(traceId);
  assertThat(span.getParentSpanId()).isEqualTo(parentSpanId);
  assertThat(span.getSpanId()).isEqualTo(spanId);
  assertThat(span.getSpanName()).isEqualTo(spanName);
  assertThat(span.isSampleable()).isEqualTo(sampleableForFullyCompleteSpan);
  assertThat(span.getUserId()).isEqualTo(userId);
  assertThat(span.getSpanStartTimeEpochMicros()).isEqualTo(startTimeEpochMicrosForFullyCompleteSpan);
  assertThat(span.getSpanStartTimeNanos()).isEqualTo(startTimeNanosForFullyCompleteSpan);
  assertThat(span.getSpanPurpose()).isEqualTo(spanPurposeForFullyCompletedSpan);
  assertThat(span.isCompleted()).isTrue();
  assertThat(span.getDurationNanos()).isEqualTo(durationNanosForFullyCompletedSpan);
  assertThat(span.getTags()).isEqualTo(tags);
  assertThat(span.getTimestampedAnnotations()).isEqualTo(annotations);
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void public_constructor_works_as_expected_for_incomplete_span() {
  // when
  Span span = new Span(
    traceId, parentSpanId, spanId, spanName, sampleableForFullyCompleteSpan, userId,
    spanPurposeForFullyCompletedSpan, startTimeEpochMicrosForFullyCompleteSpan,
    startTimeNanosForFullyCompleteSpan, null, tags, annotations
  );
  // then
  assertThat(span.getTraceId()).isEqualTo(traceId);
  assertThat(span.getParentSpanId()).isEqualTo(parentSpanId);
  assertThat(span.getSpanId()).isEqualTo(spanId);
  assertThat(span.getSpanName()).isEqualTo(spanName);
  assertThat(span.isSampleable()).isEqualTo(sampleableForFullyCompleteSpan);
  assertThat(span.getUserId()).isEqualTo(userId);
  assertThat(span.getSpanStartTimeEpochMicros()).isEqualTo(startTimeEpochMicrosForFullyCompleteSpan);
  assertThat(span.getSpanStartTimeNanos()).isEqualTo(startTimeNanosForFullyCompleteSpan);
  assertThat(span.getSpanPurpose()).isEqualTo(spanPurposeForFullyCompletedSpan);
  assertThat(span.isCompleted()).isFalse();
  assertThat(span.getDurationNanos()).isNull();
  assertThat(span.getTags()).isEqualTo(tags);
  assertThat(span.getTimestampedAnnotations()).isEqualTo(annotations);
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void equals_returns_false_and_hashCode_different_if_spanStartTimeEpochMicros_is_different() {
  // given
  Span fullSpan1 = createFilledOutSpan(true);
  Span fullSpan2 = createFilledOutSpan(true);
  Whitebox.setInternalState(fullSpan2, "spanStartTimeEpochMicros", fullSpan1.getSpanStartTimeEpochMicros() + 1);
  // expect
  assertThat(fullSpan1.equals(fullSpan2)).isFalse();
  assertThat(fullSpan1.hashCode()).isNotEqualTo(fullSpan2.hashCode());
}

代码示例来源:origin: Nike-Inc/wingtips

assertThat(zipkinSpan.name).isEqualTo(wingtipsSpan.getSpanName());
assertThat(zipkinSpan.parentId).isNull();
assertThat(zipkinSpan.timestamp).isEqualTo(wingtipsSpan.getSpanStartTimeEpochMicros());
assertThat(zipkinSpan.traceId).isEqualTo(unsignedLowerHexStringToLong(wingtipsSpan.getTraceId()));
assertThat(zipkinSpan.duration).isEqualTo(durationMicros);

代码示例来源:origin: Nike-Inc/wingtips

1 + TimeUnit.NANOSECONDS.toMicros(nanoTimeAfterMethodCall - nanoTimeBeforeSpanCreation);
long expectedMinTimestamp = span.getSpanStartTimeEpochMicros() + minPossibleOffsetMicros;
long expectedMaxTimestamp = span.getSpanStartTimeEpochMicros() + maxPossibleOffsetMicros;

代码示例来源:origin: Nike-Inc/wingtips

public static void verifySpanDeepEquals(
  Span spanToVerify, Span expectedSpan, boolean allowStartTimeNanosFudgeFactor
) {
  assertThat(spanToVerify.getSpanStartTimeEpochMicros()).isEqualTo(expectedSpan.getSpanStartTimeEpochMicros());
  if (allowStartTimeNanosFudgeFactor) {
    assertThat(spanToVerify.getSpanStartTimeNanos())
      .isCloseTo(expectedSpan.getSpanStartTimeNanos(), Offset.offset(TimeUnit.MILLISECONDS.toNanos(1)));
  }
  else {
    assertThat(spanToVerify.getSpanStartTimeNanos()).isEqualTo(expectedSpan.getSpanStartTimeNanos());
  }
  assertThat(spanToVerify.isCompleted()).isEqualTo(expectedSpan.isCompleted());
  assertThat(spanToVerify.getTraceId()).isEqualTo(expectedSpan.getTraceId());
  assertThat(spanToVerify.getSpanId()).isEqualTo(expectedSpan.getSpanId());
  assertThat(spanToVerify.getParentSpanId()).isEqualTo(expectedSpan.getParentSpanId());
  assertThat(spanToVerify.getSpanName()).isEqualTo(expectedSpan.getSpanName());
  assertThat(spanToVerify.isSampleable()).isEqualTo(expectedSpan.isSampleable());
  assertThat(spanToVerify.getUserId()).isEqualTo(expectedSpan.getUserId());
  assertThat(spanToVerify.getDurationNanos()).isEqualTo(expectedSpan.getDurationNanos());
  assertThat(spanToVerify.getSpanPurpose()).isEqualTo(expectedSpan.getSpanPurpose());
  assertThat(spanToVerify.getTags()).isEqualTo(expectedSpan.getTags());
  assertThat(spanToVerify.getTimestampedAnnotations()).isEqualTo(expectedSpan.getTimestampedAnnotations());
}

代码示例来源:origin: Nike-Inc/wingtips

assertThat(zipkinSpan.name).isEqualTo(wingtipsSpan.getSpanName());
assertThat(zipkinSpan.parentId).isEqualTo(unsignedLowerHexStringToLong(wingtipsSpan.getParentSpanId()));
assertThat(zipkinSpan.timestamp).isEqualTo(wingtipsSpan.getSpanStartTimeEpochMicros());
assertThat(zipkinSpan.traceId).isEqualTo(unsignedLowerHexStringToLong(wingtipsSpan.getTraceId()));
assertThat(zipkinSpan.duration).isEqualTo(durationMicros);

代码示例来源:origin: Nike-Inc/wingtips

assertThat(span.getSpanName()).isEqualTo("noparent");
assertThat(span.getParentSpanId()).isNull();
assertThat(span.getSpanStartTimeEpochMicros()).isBetween(beforeEpochMicros, afterEpochMicros);
assertThat(span.getSpanStartTimeNanos()).isBetween(beforeNanoTime, afterNanoTime);
assertThat(span.isCompleted()).isFalse();

代码示例来源:origin: Nike-Inc/wingtips

assertThat(result.getUserId()).isNull();
assertThat(result.getSpanPurpose()).isEqualTo(spanPurpose);
assertThat(result.getSpanStartTimeEpochMicros()).isBetween(beforeCallEpochMicros, afterCallEpochMicros);
assertThat(result.getSpanStartTimeNanos()).isBetween(beforeCallNanos, afterCallNanos);
assertThat(result.getDurationNanos()).isNull();

代码示例来源:origin: Nike-Inc/wingtips

assertThat(result.getUserId()).isNull();
assertThat(result.getSpanPurpose()).isEqualTo(spanPurpose);
assertThat(result.getSpanStartTimeEpochMicros()).isBetween(beforeCallEpochMicros, afterCallEpochMicros);
assertThat(result.getSpanStartTimeNanos()).isBetween(beforeCallNanos, afterCallNanos);
assertThat(result.isCompleted()).isFalse();

代码示例来源:origin: Nike-Inc/wingtips

assertThat(span.getSpanName()).isEqualTo("noparent");
assertThat(span.getParentSpanId()).isNull();
assertThat(span.getSpanStartTimeEpochMicros()).isBetween(beforeEpochMicros, afterEpochMicros);
assertThat(span.getSpanStartTimeNanos()).isBetween(beforeNanoTime, afterNanoTime);
assertThat(span.isCompleted()).isFalse();

代码示例来源:origin: Nike-Inc/wingtips

assertThat(span.getSpanName()).isEqualTo("childspan");
assertThat(span.getParentSpanId()).isEqualTo(parentSpan.getSpanId());
assertThat(span.getSpanStartTimeEpochMicros()).isBetween(beforeEpochMicros, afterEpochMicros);
assertThat(span.getSpanStartTimeNanos()).isBetween(beforeNanoTime, afterNanoTime);
assertThat(span.isCompleted()).isFalse();

代码示例来源:origin: Nike-Inc/wingtips

assertThat(span.getSpanName()).isEqualTo("childspan");
assertThat(span.getParentSpanId()).isEqualTo(parentSpan.getSpanId());
assertThat(span.getSpanStartTimeEpochMicros()).isBetween(beforeEpochMicros, afterEpochMicros);
assertThat(span.getSpanStartTimeNanos()).isBetween(beforeNanoTime, afterNanoTime);
assertThat(span.isCompleted()).isFalse();

代码示例来源:origin: Nike-Inc/wingtips

assertThat(zipkinSpan.name()).isEqualTo(wingtipsSpan.getSpanName());
assertThat(zipkinSpan.parentId()).isNull();
assertThat(zipkinSpan.timestamp()).isEqualTo(wingtipsSpan.getSpanStartTimeEpochMicros());
assertThat(zipkinSpan.traceId()).isEqualTo(wingtipsSpan.getTraceId());
assertThat(zipkinSpan.duration()).isEqualTo(durationMicros);

代码示例来源:origin: Nike-Inc/wingtips

.parentId(parentId)
.traceId(traceId)
.timestamp(wingtipsSpan.getSpanStartTimeEpochMicros())
.duration(durationMicros)
.localEndpoint(zipkinEndpoint)

代码示例来源:origin: Nike-Inc/wingtips

@Override
public zipkin.Span convertWingtipsSpanToZipkinSpan(Span wingtipsSpan, Endpoint zipkinEndpoint, String localComponentNamespace) {
  String traceId = wingtipsSpan.getTraceId();
  long startEpochMicros = wingtipsSpan.getSpanStartTimeEpochMicros();
  long durationMicros = TimeUnit.NANOSECONDS.toMicros(wingtipsSpan.getDurationNanos());
  zipkin.Span.Builder builder = createNewZipkinSpanBuilderWithSpanPurposeAnnotations(wingtipsSpan, startEpochMicros, durationMicros, zipkinEndpoint, localComponentNamespace)
    .id(nullSafeLong(wingtipsSpan.getSpanId()))
    .name(wingtipsSpan.getSpanName())
    .parentId(nullSafeLong(wingtipsSpan.getParentSpanId()))
    .timestamp(startEpochMicros)
    .traceIdHigh(traceId.length() == 32 ? nullSafeLong(traceId, 0) : 0)
    .traceId(nullSafeLong(traceId))
    .duration(durationMicros);
  
  addAllTagsToBuilderAsBinaryAnnotations(builder, wingtipsSpan.getTags(), zipkinEndpoint);
  addAllAnnotationsToBuilder(builder, wingtipsSpan.getTimestampedAnnotations(), zipkinEndpoint);
  return builder.build();
}

代码示例来源:origin: com.nike.wingtips/wingtips-zipkin

@Override
public zipkin.Span convertWingtipsSpanToZipkinSpan(Span wingtipsSpan, Endpoint zipkinEndpoint, String localComponentNamespace) {
  String traceId = wingtipsSpan.getTraceId();
  long startEpochMicros = wingtipsSpan.getSpanStartTimeEpochMicros();
  long durationMicros = TimeUnit.NANOSECONDS.toMicros(wingtipsSpan.getDurationNanos());
  zipkin.Span.Builder builder = createNewZipkinSpanBuilderWithSpanPurposeAnnotations(wingtipsSpan, startEpochMicros, durationMicros, zipkinEndpoint, localComponentNamespace)
    .id(nullSafeLong(wingtipsSpan.getSpanId()))
    .name(wingtipsSpan.getSpanName())
    .parentId(nullSafeLong(wingtipsSpan.getParentSpanId()))
    .timestamp(startEpochMicros)
    .traceIdHigh(traceId.length() == 32 ? nullSafeLong(traceId, 0) : 0)
    .traceId(nullSafeLong(traceId))
    .duration(durationMicros);
  
  addAllTagsToBuilderAsBinaryAnnotations(builder, wingtipsSpan.getTags(), zipkinEndpoint);
  addAllAnnotationsToBuilder(builder, wingtipsSpan.getTimestampedAnnotations(), zipkinEndpoint);
  return builder.build();
}

相关文章