use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class TraceContextCodecTest method testInject.
@Test
public void testInject() {
Map<String, String> carrier = new HashMap<>();
TextMapAdapter textMap = new TextMapAdapter(carrier);
long traceIdLow = 1;
long spanId = 2;
long parentId = 3;
long traceIdHigh = HexCodec.hexToUnsignedLong("c281c27976c85681", 0, 16);
JaegerSpanContext spanContext = new JaegerSpanContext(traceIdHigh, traceIdLow, spanId, parentId, (byte) 0);
traceContextCodec.inject(spanContext, textMap);
String expectedTraceContextHeader = "00-c281c27976c856810000000000000001-0000000000000002-00";
assertEquals(1, carrier.size());
assertNotNull(carrier.get(TRACE_PARENT));
assertEquals(expectedTraceContextHeader, carrier.get(TRACE_PARENT));
}
use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class TraceContextCodecTest method testDebugIdWithTraceHeader.
@Test
public void testDebugIdWithTraceHeader() {
Map<String, String> extractCarrier = new HashMap<>();
TextMapAdapter textMap = new TextMapAdapter(extractCarrier);
textMap.put(TRACE_PARENT, EXAMPLE_TRACE_PARENT);
textMap.put(Constants.DEBUG_ID_HEADER_KEY, EXAMPLE_DEBUG_ID);
JaegerSpanContext spanContext = traceContextCodec.extract(textMap);
JaegerTracer tracer = new JaegerTracer.Builder("service").withReporter(new InMemoryReporter()).build();
assertEquals("0000000000000001", spanContext.getTraceId());
JaegerSpan child = tracer.buildSpan("span").asChildOf(spanContext).start();
assertFalse(child.context().isDebug());
child.finish();
tracer.close();
}
use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class TraceContextCodecTest method testExtractWithCapitalizedTraceHeaders.
@Test
public void testExtractWithCapitalizedTraceHeaders() {
Map<String, String> extractCarrier = new HashMap<>();
TextMapAdapter textMap = new TextMapAdapter(extractCarrier);
textMap.put("Traceparent", EXAMPLE_TRACE_PARENT);
textMap.put("Tracestate", "whatever");
JaegerSpanContext spanContext = traceContextCodec.extract(textMap);
assertEquals("0000000000000001:0000000000000002:0:0", spanContext.toString());
assertEquals("whatever", spanContext.getTraceState());
}
use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class BaggageSetterTest method testInvalidBaggage.
@Test
public void testInvalidBaggage() {
when(mgr.getRestriction(SERVICE, KEY)).thenReturn(Restriction.of(false, 0));
final String value = "value";
JaegerSpanContext ctx = setter.setBaggage(jaegerSpan, KEY, value);
assertBaggageLogs(jaegerSpan, KEY, value, false, false, true);
assertNull(ctx.getBaggageItem(KEY));
assertEquals(1, metricsFactory.getCounter("jaeger_tracer_baggage_updates", "result=err"));
}
use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.
the class BaggageSetterTest method testBaggageNullValueTolerated.
@Test
public void testBaggageNullValueTolerated() {
when(mgr.getRestriction(SERVICE, KEY)).thenReturn(Restriction.of(true, 5));
final String value = null;
JaegerSpanContext ctx = setter.setBaggage(jaegerSpan, KEY, value);
assertBaggageLogs(jaegerSpan, KEY, null, false, false, false);
assertNull(ctx.getBaggageItem(KEY));
}
Aggregations