public class ThreadLocalTransitLayer extends java.lang.Object implements TransitLayer
A straightforward TransitLayer implementation based on thread-local storage. This is the out-of-the-box
transit layer implementation provided by the Tracing Plane.
It is unlikely that you will need to manually configure the Tracing Plane to use this class -- depending on the distribution you are using, it is likely to be configured by default.
Otherwise, to manually configure the ThreadLocalTransitLayer, you must configure it using the
baggage.transit property to use ThreadLocalTransitLayerFactory, e.g.:
-Dbaggage.transit=brown.tracingplane.impl.ThreadLocalTransitLayerFactory
It can alternatively be configured in your typesafe config's application.conf, e.g.:
baggage.transit = "brown.tracingplane.impl.ThreadLocalTransitLayerFactory"
| Constructor and Description |
|---|
ThreadLocalTransitLayer(BaggageProvider<BaggageContext> provider) |
| Modifier and Type | Method and Description |
|---|---|
BaggageContext |
branch()
Create and return a branched copy of the currently active baggage context.
|
byte[] |
branchBytes()
Create and return a branched, serialized copy of the currently active baggage context.
|
void |
discard()
Discard the currently active
BaggageContext. |
void |
join(BaggageContext otherContext)
Merges the contents of
otherContext into the currently active context. |
void |
join(byte[] serialized,
int offset,
int length)
Deserializes the provided context and merges it into the currently active context.
|
void |
join(java.nio.ByteBuffer serializedContext)
Deserializes the provided context and merges it into the currently active context.
|
BaggageContext |
peek()
Gets the currently active
BaggageContext. |
void |
set(BaggageContext baggage)
Discards the currently active
BaggageContext, then activates the provided baggage. |
void |
set(byte[] serialized,
int offset,
int length)
Deserializes the provided context and merges it into the currently active context.
|
void |
set(java.nio.ByteBuffer serializedContext)
Deserializes the provided context, discards any currently active context, and replaces it with the deserialized
context.
|
BaggageContext |
take()
Gets and removes the currently active
BaggageContext. |
byte[] |
takeBytes()
Gets, removes, and serializes the currently active
BaggageContext. |
void |
update(BaggageContext baggage)
Sets the currently active
BaggageContext. |
public ThreadLocalTransitLayer(BaggageProvider<BaggageContext> provider)
provider - the implementation of BaggageProvider in use by this transit layerpublic void discard()
TransitLayerBaggageContext.discard in interface TransitLayerpublic BaggageContext branch()
TransitLayerbranch in interface TransitLayerpublic byte[] branchBytes()
TransitLayerbranchBytes in interface TransitLayerpublic void join(BaggageContext otherContext)
TransitLayerotherContext into the currently active context. otherContext
should not be reused after calling this method, and should be treated as discarded.join in interface TransitLayerotherContext - another baggage context, possibly nullpublic void join(java.nio.ByteBuffer serializedContext)
TransitLayerjoin in interface TransitLayerserializedContext - a serialized baggage context, possibly nullpublic void join(byte[] serialized,
int offset,
int length)
TransitLayerjoin in interface TransitLayerpublic void set(BaggageContext baggage)
TransitLayerBaggageContext, then activates the provided baggage. If
baggage is just a modified version of the currently active BaggageContext, then it is better to use
the TransitLayer.update(BaggageContext) method instead.set in interface TransitLayerbaggage - The new baggage context to activate.public void set(java.nio.ByteBuffer serializedContext)
TransitLayerset in interface TransitLayerserializedContext - a serialized baggage context, possibly nullpublic void set(byte[] serialized,
int offset,
int length)
TransitLayerset in interface TransitLayerserialized - a serialized baggage context, possibly nulloffset - offset into the byte arraylength - length of serialized bytespublic BaggageContext take()
TransitLayerBaggageContext. After calling this method, there will be no active
BaggageContext.take in interface TransitLayerBaggageContext.public byte[] takeBytes()
TransitLayerBaggageContext. After calling this method, there will
be no active BaggageContext.takeBytes in interface TransitLayerBaggageContext.public BaggageContext peek()
TransitLayerBaggageContext. The BaggageContext instance remains active after
calling this method. Use TransitLayer.take() to if you wish to get and remove the currently active context.peek in interface TransitLayerBaggageContextpublic void update(BaggageContext baggage)
TransitLayerBaggageContext. A call to this method implies that the provided
context argument is an updated version of the active context. Conversely, if you intend to replace
the currently active context (e.g., because a different execution is beginning), use the
TransitLayer.set(BaggageContext) method.update in interface TransitLayer