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

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

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

Tracer.getSpanLoggingRepresentation介绍

暂无

代码示例

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

@DataProvider(value = {
  "JSON",
  "KEY_VALUE",
  "null"
})
@Test
public void constructor_works_as_expected(SpanLoggingRepresentation spanLoggingFormat) {
  // given
  WingtipsSpringBootProperties props = generateProps(
    false, UUID.randomUUID().toString(), spanLoggingFormat, "someTagStrategy", "someTagAdapter"
  );
  SpanLoggingRepresentation existingSpanLoggingFormat = Tracer.getInstance().getSpanLoggingRepresentation();
  SpanLoggingRepresentation expectedSpanLoggingFormat = (spanLoggingFormat == null)
                             ? existingSpanLoggingFormat
                             : spanLoggingFormat;
  // when
  WingtipsSpringBootConfiguration conf = new WingtipsSpringBootConfiguration(props);
  // then
  assertThat(conf.wingtipsProperties).isSameAs(props);
  assertThat(Tracer.getInstance().getSpanLoggingRepresentation()).isEqualTo(expectedSpanLoggingFormat);
}

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

@DataProvider(value = {
  "JSON",
  "KEY_VALUE"
}, splitBy = "\\|")
@Test
public void verify_span_serialization_methods(Tracer.SpanLoggingRepresentation serializationOption) {
  // given
  Span span = Span.generateRootSpanForNewTrace(UUID.randomUUID().toString(), SpanPurpose.LOCAL_ONLY).build();
  String expectedOutput;
  switch(serializationOption) {
    case JSON:
      expectedOutput = span.toJSON();
      break;
    case KEY_VALUE:
      expectedOutput = span.toKeyValueString();
      break;
    default:
      throw new IllegalArgumentException("Unhandled option: " + serializationOption);
  }
  Tracer.getInstance().setSpanLoggingRepresentation(serializationOption);
  // then
  assertThat(Tracer.getInstance().getSpanLoggingRepresentation()).isEqualTo(serializationOption);
  // and when
  String serializedString = Tracer.getInstance().serializeSpanToDesiredStringRepresentation(span);
  // then
  assertThat(serializedString).isEqualTo(expectedOutput);
}

相关文章