use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class B3TextMapCodecTest method testInject128BitTraceId.
@Test
public void testInject128BitTraceId() {
DelegatingTextMap textMap = new DelegatingTextMap();
long traceIdLow = 1;
long traceIdHigh = 2;
long spanId = 3;
long parentId = 4;
b3Codec.inject(new JaegerSpanContext(traceIdHigh, traceIdLow, spanId, parentId, SAMPLED), textMap);
final String traceId = textMap.get(B3TextMapCodec.TRACE_ID_NAME);
assertEquals(traceIdLow, HexCodec.lowerHexToUnsignedLong(traceId).longValue());
assertEquals(traceIdHigh, HexCodec.higherHexToUnsignedLong(traceId).longValue());
}
use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class B3TextMapCodecTest method testInject.
@Test
public void testInject() {
DelegatingTextMap textMap = new DelegatingTextMap();
long traceIdLow = 1;
long spanId = 2;
long parentId = 3;
b3Codec.inject(new JaegerSpanContext(0L, traceIdLow, spanId, parentId, SAMPLED), textMap);
assertTrue(textMap.containsKey(B3TextMapCodec.TRACE_ID_NAME));
assertTrue(textMap.containsKey(B3TextMapCodec.SPAN_ID_NAME));
}
use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class TextMapCodecTest method testContextAsStringWith128BitTraceId.
@Test
public void testContextAsStringWith128BitTraceId() {
long traceIdLow = 1L;
long traceIdHigh = 2L;
long spanId = 3L;
long parentId = 4L;
byte flags = (byte) 5;
JaegerSpanContext context = new JaegerSpanContext(traceIdHigh, traceIdLow, spanId, parentId, flags);
assertEquals("00000000000000020000000000000001:0000000000000003:0000000000000004:5", TextMapCodec.contextAsString(context));
}
use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class TextMapCodecTest method testInjectDoNotEncodeSpanContext.
@Test
public void testInjectDoNotEncodeSpanContext() {
TextMapCodec codec = new TextMapCodec(true);
Map<String, String> headers = new HashMap<>();
long traceIdLow = 42;
long spanId = 1;
long parentId = 0;
codec.inject(new JaegerSpanContext(0L, traceIdLow, spanId, parentId, (byte) 1), new TextMapAdapter(headers));
String traceId = headers.get("uber-trace-id");
assertEquals("000000000000002a:0000000000000001:0:1", traceId);
}
use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class TextMapCodecTest method testExtractSupportNonEncodedSpanContext.
@Test
public void testExtractSupportNonEncodedSpanContext() {
Map<String, String> headers = new HashMap<>();
headers.put("uber-trace-id", "2a:1:0:1");
TextMapCodec codec = new TextMapCodec(true);
JaegerSpanContext context = codec.extract(new TextMapAdapter(headers));
assertEquals(42, context.getTraceIdLow());
assertEquals(0L, context.getTraceIdHigh());
assertEquals(1L, context.getSpanId());
assertTrue(context.isSampled());
}
Aggregations