public class Baggage
extends java.lang.Object
The static API for manipulating BaggageContext
instances using the default BaggageProvider
.
Use of the Baggage
API depends on a BaggageProvider
being configured. Typically, this is done
automatically by the Tracing Plane distribution that you use. However, if this is not the case, or if you wish to
override the BaggageProvider
implementation in use, then set the baggage.provider
property to
the BaggageProviderFactory
of your choice.
Modifier and Type | Method and Description |
---|---|
static BaggageContext |
branch(BaggageContext from)
Create and return a branched copy
from . |
static BaggageContext |
deserialize(byte[] serialized)
Deserialize the provided serialized baggage representation.
|
static BaggageContext |
deserialize(byte[] serialized,
int offset,
int length)
Deserialize the provided serialized baggage representation.
|
static BaggageContext |
deserialize(java.nio.ByteBuffer buf)
Deserialize the provided serialized baggage representation.
|
static void |
discard(BaggageContext baggage)
Discards
baggage , indicating that the instance will not be used again. |
static BaggageContext |
join(BaggageContext left,
BaggageContext right)
Merge the contents of
left and right and return as baggage. |
static BaggageContext |
newInstance() |
static byte[] |
serialize(BaggageContext baggage)
Serialize the provided baggage instance to its byte representation.
|
static byte[] |
serialize(BaggageContext baggage,
int maximumSerializedSize)
Serialize the provided baggage instance to its byte representation and trim the baggage so that its serialized
size is
<= maximumSerializedSize . |
public static BaggageContext newInstance()
B
, which may be null to indicate an empty baggagepublic static void discard(BaggageContext baggage)
baggage
, indicating that the instance will not be used again. This method is useful, but
not required. Its purpose is to enable BaggageContext
implementations to do things like reference
counting, which is an optimization. Failing to discard baggage instances will have no bad side effects.baggage
- a baggage contextpublic static BaggageContext branch(BaggageContext from)
from
. Typically, this will just duplicate from
or
increment a reference count. Sometimes it will create a new instance, or even modify the contents of
from
.from
- a baggage instance, possibly nullfrom
, possibly nullpublic static BaggageContext join(BaggageContext left, BaggageContext right)
left
and right
and return as baggage. left
and
right
should be treated as discarded (or reused) after this method call.left
- a baggage instance, possibly nullright
- a baggage instance, possibly nullleft
and right
public static BaggageContext deserialize(byte[] serialized)
serialized
- a serialized baggagepublic static BaggageContext deserialize(byte[] serialized, int offset, int length)
serialized
- a serialized baggageoffset
- offset into the array where the baggage bytes beginlength
- lenft of the baggage bytespublic static BaggageContext deserialize(java.nio.ByteBuffer buf)
buf
- a serialized baggagepublic static byte[] serialize(BaggageContext baggage)
#branch(Baggage)
is also being called prior to serialization.baggage
- a baggage instance to serialize, possibly nullbaggage
, which might be null or an empty byte arraypublic static byte[] serialize(BaggageContext baggage, int maximumSerializedSize)
<= maximumSerializedSize
. This method should behave as though #branch(Baggage)
is also
being called prior to serialization.baggage
- a baggage instance to serialize, possibly nullmaximumSerializedSize
- the maximum size in bytes of the serialized baggage.baggage
, which might be null or an empty byte array