Search in sources :

Example 16 with JaegerSpanContext

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"));
}
Also used : JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext) Test(org.junit.Test)

Example 17 with JaegerSpanContext

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());
}
Also used : JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext) Test(org.junit.Test)

Example 18 with JaegerSpanContext

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();
}
Also used : TextMapAdapter(io.opentracing.propagation.TextMapAdapter) JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext) Test(org.junit.Test)

Example 19 with JaegerSpanContext

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();
}
Also used : TextMapAdapter(io.opentracing.propagation.TextMapAdapter) JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext) Test(org.junit.Test)

Example 20 with JaegerSpanContext

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());
}
Also used : HashMap(java.util.HashMap) TextMapAdapter(io.opentracing.propagation.TextMapAdapter) JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext) Test(org.junit.Test)

Aggregations

JaegerSpanContext (io.jaegertracing.internal.JaegerSpanContext)68 Test (org.junit.Test)59 HashMap (java.util.HashMap)20 TextMapAdapter (io.opentracing.propagation.TextMapAdapter)19 JaegerSpan (io.jaegertracing.internal.JaegerSpan)10 JaegerTracer (io.jaegertracing.internal.JaegerTracer)8 Response (javax.ws.rs.core.Response)7 TextMap (io.opentracing.propagation.TextMap)6 CodecConfiguration (io.jaegertracing.Configuration.CodecConfiguration)4 ReporterConfiguration (io.jaegertracing.Configuration.ReporterConfiguration)4 SamplerConfiguration (io.jaegertracing.Configuration.SamplerConfiguration)4 SenderConfiguration (io.jaegertracing.Configuration.SenderConfiguration)4 List (java.util.List)3 ObservedSpan (io.jaegertracing.crossdock.api.ObservedSpan)2 TestBinaryCarrier (io.jaegertracing.internal.propagation.TestBinaryCarrier)2 InMemoryReporter (io.jaegertracing.internal.reporters.InMemoryReporter)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1 Endpoint (com.twitter.zipkin.thriftjava.Endpoint)1