Search in sources :

Example 56 with JaegerSpanContext

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

Example 57 with JaegerSpanContext

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

Example 58 with JaegerSpanContext

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

Example 59 with JaegerSpanContext

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

Example 60 with JaegerSpanContext

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());
}
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