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

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

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

Span.addTimestampedAnnotation介绍

[英]Adds the given TimestampedAnnotation to this Span's #getTimestampedAnnotations() list.
[中]将给定的TimeStampedAnnotations添加到此Span的#getTimestampedAnnotations()列表中。

代码示例

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

/**
 * Adds a {@link TimestampedAnnotation} to this Span's {@link #getTimestampedAnnotations()} list, with the current
 * time in epoch microseconds as the timestamp and the given value.
 *
 * <p>NOTE: Since the span keeps track of its duration in nanoseconds, this method results in a
 * {@link TimestampedAnnotation} with a {@link TimestampedAnnotation#getTimestampEpochMicros()} that is more
 * accurate than if you created the {@link TimestampedAnnotation} directly (i.e. this method uses {@link
 * TimestampedAnnotation#forEpochMicrosWithNanoOffset(long, long, String)}). This method should therefore be
 * used anytime you want to add an annotation to a Span with a timestamp of "right now".
 *
 * @param value The desired {@link TimestampedAnnotation#getValue()} for the new annotation.
 */
public void addTimestampedAnnotationForCurrentTime(String value) {
  addTimestampedAnnotation(
    TimestampedAnnotation.forEpochMicrosWithNanoOffset(
      spanStartTimeEpochMicros,
      System.nanoTime() - spanStartTimeNanos,
      value
    )
  );
}

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

subspan.addTimestampedAnnotation(TimestampedAnnotation.forEpochMicrosWithNanoOffset(
  subspan.getSpanStartTimeEpochMicros(),
  -connectionSetupTimeNanos,
subspan.addTimestampedAnnotation(TimestampedAnnotation.forEpochMicros(
  subspan.getSpanStartTimeEpochMicros(),
  proxySpanTaggingStrategy.connFinishAnnotationName()

代码示例来源:origin: com.nike.riposte/riposte-core

subspan.addTimestampedAnnotation(TimestampedAnnotation.forEpochMicrosWithNanoOffset(
  subspan.getSpanStartTimeEpochMicros(),
  -connectionSetupTimeNanos,
subspan.addTimestampedAnnotation(TimestampedAnnotation.forEpochMicros(
  subspan.getSpanStartTimeEpochMicros(),
  proxySpanTaggingStrategy.connFinishAnnotationName()

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

@Test
public void addTimestampedAnnotation_works_as_expected() {
  // given
  Span span = Span.newBuilder("foo", SpanPurpose.CLIENT).build();
  TimestampedAnnotation annotationMock = mock(TimestampedAnnotation.class);
  
  // when
  span.addTimestampedAnnotation(annotationMock);
  // then
  assertThat(span.getTimestampedAnnotations())
    .hasSize(1)
    .containsExactly(annotationMock);
}

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

@Test
public void equals_returns_false_and_hashCode_different_if_annotations_are_different() {
  // given
  Span fullSpan1 = createFilledOutSpan(true);
  Span fullSpan2 = createFilledOutSpan(true);
  fullSpan1.addTimestampedAnnotation(TimestampedAnnotation.forCurrentTime("foo"));
  // expect
  assertThat(fullSpan1.equals(fullSpan2)).isFalse();
  assertThat(fullSpan1.hashCode()).isNotEqualTo(fullSpan2.hashCode());
}

相关文章