public class TracingContext extends Object implements AbstractTracerContext
TracingContext represents a core tracing logic controller. It build the final TracingContext, by the stack mechanism, which is similar with the codes work.
In opentracing concept, it means, all spans in a segment tracing context(thread) are CHILD_OF relationship, but no
FOLLOW_OF.
In skywalking core concept, FOLLOW_OF is an abstract concept when cross-process MQ or cross-thread async/batch tasks
happen, we used TraceSegmentRef for these scenarios. Check TraceSegmentRef which is from ContextCarrier or ContextSnapshot.| Modifier and Type | Class and Description |
|---|---|
static class |
TracingContext.ListenerManager
The
ListenerManager represents an event notify for every registered listener, which are notified
when the TracingContext finished, and segment is ready for further process. |
| Modifier and Type | Method and Description |
|---|---|
AbstractSpan |
activeSpan() |
void |
asyncStop(AsyncSpan span)
The given span could be stopped officially.
|
AbstractTracerContext |
awaitFinishAsync()
Notify this context, current span is going to be finished async in another thread.
|
ContextSnapshot |
capture()
Capture the snapshot of current context.
|
void |
continued(ContextSnapshot snapshot)
Continue the context from the given snapshot of parent thread.
|
AbstractSpan |
createEntrySpan(String operationName)
Create an entry span
|
AbstractSpan |
createExitSpan(String operationName,
String remotePeer)
Create an exit span
|
AbstractSpan |
createLocalSpan(String operationName)
Create a local span
|
void |
extract(ContextCarrier carrier)
Extract the carrier to build the reference for the pre segment.
|
String |
getReadableGlobalTraceId()
Get the global trace id, if needEnhance.
|
void |
inject(ContextCarrier carrier)
Inject the context into the given carrier, only when the active span is an exit one.
|
boolean |
stopSpan(AbstractSpan span)
Stop the given span, if and only if this one is the top element of
activeSpanStack. |
public void inject(ContextCarrier carrier)
inject in interface AbstractTracerContextcarrier - to carry the context for crossing process.IllegalStateException - if the active span isn't an exit one. Ref to AbstractTracerContext.inject(ContextCarrier)public void extract(ContextCarrier carrier)
extract in interface AbstractTracerContextcarrier - carried the context from a cross-process segment. Ref to AbstractTracerContext.extract(ContextCarrier)public ContextSnapshot capture()
capture in interface AbstractTracerContextAbstractTracerContext.capture()public void continued(ContextSnapshot snapshot)
continued in interface AbstractTracerContextsnapshot - from capture() in the parent thread. Ref to AbstractTracerContext.continued(ContextSnapshot)public String getReadableGlobalTraceId()
AbstractTracerContextgetReadableGlobalTraceId in interface AbstractTracerContextpublic AbstractSpan createEntrySpan(String operationName)
createEntrySpan in interface AbstractTracerContextoperationName - most likely a service nameEntrySpanpublic AbstractSpan createLocalSpan(String operationName)
createLocalSpan in interface AbstractTracerContextoperationName - most likely a local method signature, or business name.LocalSpanpublic AbstractSpan createExitSpan(String operationName, String remotePeer)
createExitSpan in interface AbstractTracerContextoperationName - most likely a service name of remoteremotePeer - the network id(ip:port, hostname:port or ip1:port1,ip2,port, etc.)ExitSpanpublic AbstractSpan activeSpan()
activeSpan in interface AbstractTracerContextactiveSpanStackpublic boolean stopSpan(AbstractSpan span)
activeSpanStack. Because the tracing
core must make sure the span must match in a stack module, like any program did.stopSpan in interface AbstractTracerContextspan - to finishpublic AbstractTracerContext awaitFinishAsync()
AbstractTracerContextawaitFinishAsync in interface AbstractTracerContextpublic void asyncStop(AsyncSpan span)
AbstractTracerContextasyncStop in interface AbstractTracerContextspan - to be stopped.Copyright © 2019 The Apache Software Foundation. All rights reserved.