本文整理了Java中com.nike.wingtips.Tracer.setSpanLoggingRepresentation()
方法的一些代码示例,展示了Tracer.setSpanLoggingRepresentation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tracer.setSpanLoggingRepresentation()
方法的具体详情如下:
包路径:com.nike.wingtips.Tracer
类名称:Tracer
方法名:setSpanLoggingRepresentation
[英]Sets the option for how spans will be serialized when they are completed and logged.
[中]设置跨距完成并记录后如何序列化跨距的选项。
代码示例来源:origin: Nike-Inc/wingtips
@Autowired
public WingtipsSpringBootConfiguration(WingtipsSpringBootProperties wingtipsProperties) {
this.wingtipsProperties = wingtipsProperties;
// Set the span logging representation if specified in the wingtips properties.
if (wingtipsProperties.getSpanLoggingFormat() != null) {
Tracer.getInstance().setSpanLoggingRepresentation(wingtipsProperties.getSpanLoggingFormat());
}
}
代码示例来源:origin: Nike-Inc/wingtips
private Span findCompletedSpanByCriteria(Predicate<Span> criteria) {
Tracer.getInstance().setSpanLoggingRepresentation(Tracer.SpanLoggingRepresentation.KEY_VALUE);
List<Span> matchingSpans = spanRecorder.completedSpans.stream().filter(criteria).collect(Collectors.toList());
assertThat(matchingSpans)
.withFailMessage(
"Expected to find exactly 1 span matching the specified criteria - instead found: "
+ matchingSpans.size()
)
.hasSize(1);
return matchingSpans.get(0);
}
代码示例来源:origin: Nike-Inc/wingtips
@Test(expected = IllegalArgumentException.class)
public void setSpanLoggingRepresentation_blows_up_if_spanLoggingRepresentation_is_null() {
// expect
Tracer.getInstance().setSpanLoggingRepresentation(null);
}
代码示例来源: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);
}
代码示例来源:origin: Nike-Inc/wingtips
private void resetTracer() {
Tracer.getInstance().completeRequestSpan();
Tracer.getInstance().setRootSpanSamplingStrategy(new SampleAllTheThingsStrategy());
for (SpanLifecycleListener listener : new ArrayList<>(Tracer.getInstance().getSpanLifecycleListeners())) {
Tracer.getInstance().removeSpanLifecycleListener(listener);
}
Tracer.getInstance().setSpanLoggingRepresentation(Tracer.SpanLoggingRepresentation.JSON);
}
内容来源于网络,如有侵权,请联系作者删除!