本文整理了Java中com.nike.wingtips.Tracer.unregisterFromThread()
方法的一些代码示例,展示了Tracer.unregisterFromThread()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tracer.unregisterFromThread()
方法的具体详情如下:
包路径:com.nike.wingtips.Tracer
类名称:Tracer
方法名:unregisterFromThread
[英]"Unregisters" the current span stack from this thread, removes span-related info from the logging MDC, and returns the span stack that was unregistered so it can be stored and re-registered later (if desired). This is used in asynchronous projects/frameworks where multiple in-progress requests might be handled by the same thread before any of the requests can finish (e.g. Netty, where the worker I/O threads might process a portion of request A, flip over to request B to do some work, then go back to request A, etc). This method lets you unregister the tracing info from the current thread when it is about to switch to processing a different request so the tracing info can be stored in some kind of request context state that follows the request, and won't pollute the thread's span stack and MDC info when the new request starts being processed.
When processing switches back to the original request, you can call #registerWithThread(java.util.Deque) to set the thread's span stack and MDC info back to the way it was when you first called this unregister method for the original request.
WARNING: This method should NOT be called if you're in an environment where a single thread is guaranteed to process a request from start to finish without jumping to a different request in the middle. In that case just use the normal start and complete span methods and ignore this method.
[中]“注销”此线程中的当前跨度堆栈,从日志记录MDC中删除与跨度相关的信息,并返回已注销的跨度堆栈,以便以后可以存储和重新注册(如果需要)。这在异步项目/框架中使用,其中多个进行中的请求可能在任何请求完成之前由同一个线程处理(例如,Netty,工作I/O线程可能处理请求a的一部分,翻转到请求B来做一些工作,然后返回到请求a,等等)。此方法允许您在当前线程即将切换到处理另一个请求时从其注销跟踪信息,以便跟踪信息可以存储在请求之后的某种请求上下文状态中,并且在开始处理新请求时不会污染线程的跨度堆栈和MDC信息。
当处理切换回原始请求时,可以调用#registerWithThread(java.util.Deque)将线程的跨度堆栈和MDC信息设置回最初为原始请求调用此unregister方法时的状态。
警告:如果您在一个线程保证从一开始到结束处理一个请求而不跳转到中间的不同请求的环境中,则不应该调用此方法。在这种情况下,只需使用正常的开始和完成跨度方法,而忽略此方法。
代码示例来源:origin: Nike-Inc/wingtips
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
}
代码示例来源:origin: Nike-Inc/wingtips
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
}
代码示例来源:origin: Nike-Inc/wingtips
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
}
代码示例来源:origin: Nike-Inc/wingtips
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
}
代码示例来源:origin: Nike-Inc/wingtips
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
}
代码示例来源:origin: Nike-Inc/wingtips
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
}
代码示例来源:origin: Nike-Inc/wingtips
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
}
代码示例来源:origin: Nike-Inc/wingtips
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
}
代码示例来源:origin: Nike-Inc/wingtips
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
}
代码示例来源:origin: Nike-Inc/wingtips
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
}
代码示例来源:origin: Nike-Inc/wingtips
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
}
代码示例来源:origin: Nike-Inc/wingtips
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
removeSpanRecorderLifecycleListener();
}
代码示例来源:origin: Nike-Inc/wingtips
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
removeSpanRecorderLifecycleListener();
}
代码示例来源:origin: Nike-Inc/wingtips
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
removeSpanRecorderLifecycleListener();
}
代码示例来源:origin: Nike-Inc/riposte
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
removeSpanRecorderLifecycleListener();
}
代码示例来源:origin: Nike-Inc/riposte
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
removeSpanRecorderLifecycleListener();
}
代码示例来源:origin: Nike-Inc/wingtips
public static void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
List<SpanLifecycleListener> listeners = new ArrayList<>(Tracer.getInstance().getSpanLifecycleListeners());
for (SpanLifecycleListener listener : listeners) {
Tracer.getInstance().removeSpanLifecycleListener(listener);
}
}
代码示例来源:origin: Nike-Inc/wingtips
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
List<SpanLifecycleListener> listeners = new ArrayList<>(Tracer.getInstance().getSpanLifecycleListeners());
for (SpanLifecycleListener listener : listeners) {
Tracer.getInstance().removeSpanLifecycleListener(listener);
}
}
代码示例来源:origin: Nike-Inc/riposte
private void resetTracing() {
MDC.clear();
Tracer.getInstance().unregisterFromThread();
removeSpanRecorderLifecycleListener();
spanRecorder = new SpanRecorder();
Tracer.getInstance().addSpanLifecycleListener(spanRecorder);
}
代码示例来源:origin: Nike-Inc/riposte
private Pair<Deque<Span>, Map<String, String>> setupStateWithNewSpan(String spanName) {
Deque<Span> origSpanInfo = Tracer.getInstance().unregisterFromThread();
Map<String, String> origMdcInfo = MDC.getCopyOfContextMap();
Tracer.getInstance().startRequestWithRootSpan(spanName);
Pair<Deque<Span>, Map<String, String>> infoForStatePair = AsyncNettyHelper.linkTracingAndMdcToCurrentThread(origSpanInfo, origMdcInfo);
state.setDistributedTraceStack(infoForStatePair.getLeft());
state.setLoggerMdcContextMap(infoForStatePair.getRight());
return infoForStatePair;
}
内容来源于网络,如有侵权,请联系作者删除!