- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.nike.wingtips.zipkin.util.ZipkinSpanSender.handleSpan()
方法的一些代码示例,展示了ZipkinSpanSender.handleSpan()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipkinSpanSender.handleSpan()
方法的具体详情如下:
包路径:com.nike.wingtips.zipkin.util.ZipkinSpanSender
类名称:ZipkinSpanSender
方法名:handleSpan
[英]"Handles" the given Zipkin span. In a typical implementation spans are stored in a threadsafe collection for batching until some trigger is hit that causes the span batch to be sent to the Zipkin server (e.g. scheduled job that sends batches every x period of time, or after a batch size threshold is hit, or both).
IMPORTANT NOTE: DO NOT BLOCK IN THIS METHOD'S IMPLEMENTATION. If you send data to the Zipkin server directly based on this method call then it should be split out into a separate thread to do the work. The only thing that should happen on the calling thread is to put the span into a queue for later processing, or spinning off a job on a separate thread.
[中]“处理”给定的Zipkin跨度。在典型的实现中,跨度存储在threadsafe集合中进行批处理,直到触发某个触发器,导致跨度批处理被发送到Zipkin服务器(例如,每x个时间段发送一次批处理的计划作业,或在达到批处理大小阈值后发送批处理,或两者兼而有之)。
重要提示:不要在该方法的实现中阻塞。如果基于此方法调用直接将数据发送到Zipkin服务器,则应将其拆分为单独的线程来执行该工作。在调用线程上应该做的唯一事情是将跨度放入队列以供以后处理,或者在单独的线程上拆分作业。
代码示例来源:origin: Nike-Inc/wingtips
@Override
public void spanCompleted(Span span) {
try {
zipkin.Span zipkinSpan = zipkinSpanConverter.convertWingtipsSpanToZipkinSpan(span, zipkinEndpoint, localComponentNamespace);
zipkinSpanSender.handleSpan(zipkinSpan);
}
catch(Throwable ex) {
long currentBadSpanCount = spanHandlingErrorCounter.incrementAndGet();
// Only log once every MIN_SPAN_HANDLING_ERROR_LOG_INTERVAL_MILLIS time interval to prevent log spam from a malicious (or broken) caller.
long currentTimeMillis = System.currentTimeMillis();
long timeSinceLastLogMsgMillis = currentTimeMillis - lastSpanHandlingErrorLogTimeEpochMillis;
if (timeSinceLastLogMsgMillis >= MIN_SPAN_HANDLING_ERROR_LOG_INTERVAL_MILLIS) {
// We're not synchronizing the read and write to lastSpanHandlingErrorLogTimeEpochMillis, and that's ok. If we get a few extra
// log messages due to a race condition it's not the end of the world - we're still satisfying the goal of not allowing a
// malicious caller to endlessly spam the logs.
lastSpanHandlingErrorLogTimeEpochMillis = currentTimeMillis;
zipkinConversionOrReportingErrorLogger.warn(
"There have been {} spans that were not zipkin compatible, or that experienced an error during span handling. Latest example: "
+ "wingtips_span_with_error=\"{}\", conversion_or_handling_error=\"{}\"",
currentBadSpanCount, span.toKeyValueString(), ex.toString());
}
}
}
}
代码示例来源:origin: com.nike.wingtips/wingtips-zipkin
@Override
public void spanCompleted(Span span) {
try {
zipkin.Span zipkinSpan = zipkinSpanConverter.convertWingtipsSpanToZipkinSpan(span, zipkinEndpoint, localComponentNamespace);
zipkinSpanSender.handleSpan(zipkinSpan);
}
catch(Throwable ex) {
long currentBadSpanCount = spanHandlingErrorCounter.incrementAndGet();
// Only log once every MIN_SPAN_HANDLING_ERROR_LOG_INTERVAL_MILLIS time interval to prevent log spam from a malicious (or broken) caller.
long currentTimeMillis = System.currentTimeMillis();
long timeSinceLastLogMsgMillis = currentTimeMillis - lastSpanHandlingErrorLogTimeEpochMillis;
if (timeSinceLastLogMsgMillis >= MIN_SPAN_HANDLING_ERROR_LOG_INTERVAL_MILLIS) {
// We're not synchronizing the read and write to lastSpanHandlingErrorLogTimeEpochMillis, and that's ok. If we get a few extra
// log messages due to a race condition it's not the end of the world - we're still satisfying the goal of not allowing a
// malicious caller to endlessly spam the logs.
lastSpanHandlingErrorLogTimeEpochMillis = currentTimeMillis;
zipkinConversionOrReportingErrorLogger.warn(
"There have been {} spans that were not zipkin compatible, or that experienced an error during span handling. Latest example: "
+ "wingtips_span_with_error=\"{}\", conversion_or_handling_error=\"{}\"",
currentBadSpanCount, span.toKeyValueString(), ex.toString());
}
}
}
}
代码示例来源:origin: Nike-Inc/wingtips
@Test
public void spanCompleted_does_not_propagate_exceptions_generated_by_span_sender() {
// given
doThrow(new RuntimeException("kaboom")).when(spanSenderMock).handleSpan(any(zipkin.Span.class));
// when
Throwable ex = catchThrowable(new ThrowableAssert.ThrowingCallable() {
@Override
public void call() throws Throwable {
listener.spanCompleted(spanMock);
}
});
// then
verify(spanSenderMock).handleSpan(any(zipkin.Span.class));
assertThat(ex).isNull();
}
代码示例来源:origin: Nike-Inc/wingtips
@Test
public void spanCompleted_logs_error_during_handling_if_time_since_lastSpanHandlingErrorLogTimeEpochMillis_is_greater_than_MIN_SPAN_HANDLING_ERROR_LOG_INTERVAL_MILLIS() throws InterruptedException {
// given
Logger loggerMock = mock(Logger.class);
Whitebox.setInternalState(listener, "zipkinConversionOrReportingErrorLogger", loggerMock);
long lastLogTimeToSet = System.currentTimeMillis() - (MIN_SPAN_HANDLING_ERROR_LOG_INTERVAL_MILLIS + 10);
Whitebox.setInternalState(listener, "lastSpanHandlingErrorLogTimeEpochMillis", lastLogTimeToSet);
doThrow(new RuntimeException("kaboom")).when(spanSenderMock).handleSpan(any(zipkin.Span.class));
// when
long before = System.currentTimeMillis();
listener.spanCompleted(spanMock);
long after = System.currentTimeMillis();
// then
verify(loggerMock).warn(anyString(), anyLong(), anyString(), anyString());
// Also verify that the lastSpanHandlingErrorLogTimeEpochMillis value got updated.
assertThat((long)Whitebox.getInternalState(listener, "lastSpanHandlingErrorLogTimeEpochMillis")).isBetween(before, after);
}
代码示例来源:origin: Nike-Inc/wingtips
@Test
public void spanCompleted_does_not_log_an_error_during_handling_if_time_since_lastSpanHandlingErrorLogTimeEpochMillis_is_less_than_MIN_SPAN_HANDLING_ERROR_LOG_INTERVAL_MILLIS() throws InterruptedException {
// given
Logger loggerMock = mock(Logger.class);
Whitebox.setInternalState(listener, "zipkinConversionOrReportingErrorLogger", loggerMock);
long lastLogTimeToSet = System.currentTimeMillis() - (MIN_SPAN_HANDLING_ERROR_LOG_INTERVAL_MILLIS - 1000);
Whitebox.setInternalState(listener, "lastSpanHandlingErrorLogTimeEpochMillis", lastLogTimeToSet);
doThrow(new RuntimeException("kaboom")).when(spanSenderMock).handleSpan(any(zipkin.Span.class));
// when
listener.spanCompleted(spanMock);
// then
verifyZeroInteractions(loggerMock);
// Also verify that the lastSpanHandlingErrorLogTimeEpochMillis value was *not* updated.
assertThat((long)Whitebox.getInternalState(listener, "lastSpanHandlingErrorLogTimeEpochMillis")).isEqualTo(lastLogTimeToSet);
}
}
代码示例来源:origin: Nike-Inc/wingtips
@Test
public void spanCompleted_converts_to_zipkin_span_and_passes_it_to_zipkinSpanSender() {
// given
zipkin.Span zipkinSpan = zipkin.Span.builder().traceId(42).id(4242).name("foo").build();
doReturn(zipkinSpan).when(spanConverterMock).convertWingtipsSpanToZipkinSpan(any(Span.class), any(Endpoint.class), any(String.class));
// when
listener.spanCompleted(spanMock);
// then
verify(spanConverterMock).convertWingtipsSpanToZipkinSpan(spanMock, listener.zipkinEndpoint, localComponentNamespace);
verify(spanSenderMock).handleSpan(zipkinSpan);
}
本文整理了Java中com.nike.wingtips.tags.ZipkinHttpTagStrategy类的一些代码示例,展示了ZipkinHttpTagStrategy类的具体用法。这些代码示例
本文整理了Java中com.nike.wingtips.zipkin.util.ZipkinSpanSenderDefaultHttpImpl类的一些代码示例,展示了ZipkinSpanSenderD
本文整理了Java中com.nike.wingtips.zipkin.util.ZipkinSpanSender类的一些代码示例,展示了ZipkinSpanSender类的具体用法。这些代码示例主要来
本文整理了Java中com.nike.wingtips.tags.ZipkinHttpTagStrategy.putTagIfValueIsNotBlank()方法的一些代码示例,展示了ZipkinH
本文整理了Java中com.nike.wingtips.tags.ZipkinHttpTagStrategy.getDefaultInstance()方法的一些代码示例,展示了ZipkinHttpTa
本文整理了Java中com.nike.wingtips.zipkin.util.ZipkinSpanSenderDefaultHttpImpl.()方法的一些代码示例,展示了ZipkinSpanSen
本文整理了Java中com.nike.wingtips.zipkin.util.ZipkinSpanSenderDefaultHttpImpl.configureScheduledExecutorSe
本文整理了Java中com.nike.wingtips.zipkin.util.ZipkinSpanSender.handleSpan()方法的一些代码示例,展示了ZipkinSpanSender.h
我是一名优秀的程序员,十分优秀!