public final class B3SingleFormat extends Object
b3: {x-b3-traceid}-{x-b3-spanid}-{if x-b3-flags 'd' else x-b3-sampled}-{x-b3-parentspanid}
For example, a sampled root span would look like:
4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-1
... a not yet sampled root span would look like:
4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7
... and a debug RPC child span would look like:
4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-d-5b4185666d50f68b
Like normal B3, it is valid to omit trace identifiers in order to only propagate a sampling decision. For example, the following are valid downstream hints:
b3: 0b3: 1b3: dX-B3-Flags: 1), is a boosted sample signal which is recorded
to ensure it reaches the collector tier. See SamplingFlags.debug().
See B3 Propagation
| Modifier and Type | Method | Description |
|---|---|---|
static TraceContextOrSamplingFlags |
parseB3SingleFormat(CharSequence b3) |
|
static TraceContextOrSamplingFlags |
parseB3SingleFormat(CharSequence b3,
int beginIndex,
int endIndex) |
|
static String |
writeB3SingleFormat(TraceContext context) |
Writes all B3 defined fields in the trace context to a hyphen delimited string.
|
static byte[] |
writeB3SingleFormatAsBytes(TraceContext context) |
Like
writeB3SingleFormatAsBytes(TraceContext), but for carriers with byte array or
byte buffer values. |
static String |
writeB3SingleFormatWithoutParentId(TraceContext context) |
Writes all B3 defined fields in the trace context, except
parent ID, to a hyphen delimited string. |
static byte[] |
writeB3SingleFormatWithoutParentIdAsBytes(TraceContext context) |
Like
writeB3SingleFormatWithoutParentId(TraceContext), but for carriers with byte
array or byte buffer values. |
public static String writeB3SingleFormatWithoutParentId(TraceContext context)
parent ID, to a hyphen delimited string.
This is appropriate for receivers who understand "b3" single header format, and always do
work in a child span. For example, message consumers always do work in child spans, so message
producers can use this format to save bytes on the wire. On the other hand, RPC clients should
use writeB3SingleFormat(TraceContext) instead, as RPC servers often share a span ID
with the client.
public static byte[] writeB3SingleFormatWithoutParentIdAsBytes(TraceContext context)
writeB3SingleFormatWithoutParentId(TraceContext), but for carriers with byte
array or byte buffer values. For example, ByteBuffer.wrap(byte[]) can wrap the result.public static String writeB3SingleFormat(TraceContext context)
The parent ID is serialized in case the receiver is
an RPC server. When downstream is known to be a messaging consumer, or a server that never
reuses a client's span ID, prefer writeB3SingleFormatWithoutParentId(TraceContext).
public static byte[] writeB3SingleFormatAsBytes(TraceContext context)
writeB3SingleFormatAsBytes(TraceContext), but for carriers with byte array or
byte buffer values. For example, ByteBuffer.wrap(byte[]) can wrap the result.@Nullable public static TraceContextOrSamplingFlags parseB3SingleFormat(CharSequence b3)
@Nullable public static TraceContextOrSamplingFlags parseB3SingleFormat(CharSequence b3, int beginIndex, int endIndex)
beginIndex - the start index, inclusiveendIndex - the end index, exclusiveCopyright © 2018 OpenZipkin. All rights reserved.