use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class BaggageSetterTest method testTruncatedBaggage.
@Test
public void testTruncatedBaggage() {
when(mgr.getRestriction(SERVICE, KEY)).thenReturn(Restriction.of(true, 5));
final String value = "0123456789";
final String expected = "01234";
JaegerSpanContext ctx = setter.setBaggage(jaegerSpan, KEY, value);
assertBaggageLogs(jaegerSpan, KEY, expected, true, false, false);
assertEquals(expected, ctx.getBaggageItem(KEY));
assertEquals(1, metricsFactory.getCounter("jaeger_tracer_baggage_truncations", ""));
assertEquals(1, metricsFactory.getCounter("jaeger_tracer_baggage_updates", "result=ok"));
}
use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class BinaryCodecTest method testContextFieldsWithNoBaggage.
/**
* Tests that the codec will include baggage from header "jaeger-baggage".
*/
@Test
public void testContextFieldsWithNoBaggage() {
final long traceIdLow = 42;
final long traceIdHigh = 2;
final long spanId = 1;
final long parentId = 22;
final byte flags = (byte) 1;
BinaryCodec codec = new BinaryCodec();
TestBinaryCarrier carrier = new TestBinaryCarrier();
codec.inject(new JaegerSpanContext(traceIdHigh, traceIdLow, spanId, parentId, flags), carrier);
JaegerSpanContext context = codec.extract(carrier);
assertTrue(carrier.buffer.remaining() == 0);
assertEquals("must have trace ID low", traceIdLow, context.getTraceIdLow());
assertEquals("must have trace ID high", traceIdHigh, context.getTraceIdHigh());
assertEquals("must have span ID", spanId, context.getSpanId());
assertEquals("must have parent ID", parentId, context.getParentId());
assertEquals("must have flags", flags, context.getFlags());
}
use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class TraceContextCodecTest method testNoTraceHeader.
@Test
public void testNoTraceHeader() {
TextMapAdapter textMap = new TextMapAdapter(new HashMap<>());
JaegerSpanContext spanContext = traceContextCodec.extract(textMap);
assertNull(spanContext);
verifyWarningNotPresent();
}
use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class TraceContextCodecTest method testInvalidTraceId.
@Test
public void testInvalidTraceId() {
TextMapAdapter textMap = new TextMapAdapter(new HashMap<>());
textMap.put(TRACE_PARENT, "00-00000000000000000000000000000000-0000000000000002-00");
JaegerSpanContext spanContext = traceContextCodec.extract(textMap);
assertNull(spanContext);
verifyWarningPresent();
}
use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class TraceContextCodecTest method testInjectWith64bit.
@Test
public void testInjectWith64bit() {
Map<String, String> carrier = new HashMap<>();
TextMapAdapter textMap = new TextMapAdapter(carrier);
traceContextCodec.inject(SPAN_CONTEXT, textMap);
assertEquals(1, carrier.size());
String traceParent = carrier.get(TRACE_PARENT);
assertEquals(EXAMPLE_TRACE_PARENT, traceParent);
JaegerSpanContext extractedContext = traceContextCodec.extract(textMap);
assertEquals("0000000000000001:0000000000000002:0:0", extractedContext.toString());
}
Aggregations