Search in sources :

Example 6 with JaegerSpanContext

use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.

the class ConfigurationTest method testDefaultCodecs.

@Test
public void testDefaultCodecs() {
    Configuration configuration = new Configuration("foo");
    long traceIdLow = 2L;
    long spanId = 11L;
    long parentId = 22L;
    JaegerSpanContext spanContext = new JaegerSpanContext(0, traceIdLow, spanId, parentId, (byte) 0);
    assertInjectExtract(configuration.getTracer(), Builtin.TEXT_MAP, spanContext, false);
    assertInjectExtract(configuration.getTracer(), Builtin.HTTP_HEADERS, spanContext, false);
    assertBinaryInjectExtract(configuration.getTracer(), spanContext);
}
Also used : SenderConfiguration(io.jaegertracing.Configuration.SenderConfiguration) CodecConfiguration(io.jaegertracing.Configuration.CodecConfiguration) ReporterConfiguration(io.jaegertracing.Configuration.ReporterConfiguration) SamplerConfiguration(io.jaegertracing.Configuration.SamplerConfiguration) JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext) Test(org.junit.Test)

Example 7 with JaegerSpanContext

use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.

the class ConfigurationTest method testPropagationJaegerAndB3.

@Test
public void testPropagationJaegerAndB3() {
    System.setProperty(Configuration.JAEGER_PROPAGATION, "jaeger,b3");
    System.setProperty(Configuration.JAEGER_SERVICE_NAME, "Test");
    long traceIdLow = 1234L;
    long spanId = 5678L;
    TestTextMap textMap = new TestTextMap();
    JaegerSpanContext spanContext = new JaegerSpanContext(0, traceIdLow, spanId, 0, (byte) 0);
    JaegerTracer tracer = Configuration.fromEnv().getTracer();
    tracer.inject(spanContext, Format.Builtin.TEXT_MAP, textMap);
    assertNotNull(textMap.get("uber-trace-id"));
    assertNotNull(textMap.get("X-B3-TraceId"));
    assertNotNull(textMap.get("X-B3-SpanId"));
    JaegerSpanContext extractedContext = tracer.extract(Format.Builtin.TEXT_MAP, textMap);
    assertEquals(traceIdLow, extractedContext.getTraceIdLow());
    assertEquals(0, extractedContext.getTraceIdHigh());
    assertEquals(spanId, extractedContext.getSpanId());
}
Also used : JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Example 8 with JaegerSpanContext

use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.

the class ConfigurationTest method testDefaultCodecsWith128BitTraceId.

@Test
public void testDefaultCodecsWith128BitTraceId() {
    Configuration configuration = new Configuration("foo").withTraceId128Bit(true);
    long traceIdLow = 2L;
    long traceIdHigh = 3L;
    long spanId = 11L;
    long parentId = 22L;
    JaegerSpanContext spanContext = new JaegerSpanContext(traceIdHigh, traceIdLow, spanId, parentId, (byte) 0);
    assertInjectExtract(configuration.getTracer(), Builtin.TEXT_MAP, spanContext, false);
    assertInjectExtract(configuration.getTracer(), Builtin.HTTP_HEADERS, spanContext, false);
    assertBinaryInjectExtract(configuration.getTracer(), spanContext);
}
Also used : SenderConfiguration(io.jaegertracing.Configuration.SenderConfiguration) CodecConfiguration(io.jaegertracing.Configuration.CodecConfiguration) ReporterConfiguration(io.jaegertracing.Configuration.ReporterConfiguration) SamplerConfiguration(io.jaegertracing.Configuration.SamplerConfiguration) JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext) Test(org.junit.Test)

Example 9 with JaegerSpanContext

use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.

the class ConfigurationTest method assertBinaryInjectExtract.

private void assertBinaryInjectExtract(JaegerTracer tracer, JaegerSpanContext contextToInject) {
    TestBinaryCarrier carrier = new TestBinaryCarrier();
    tracer.inject(contextToInject, Format.Builtin.BINARY, carrier);
    JaegerSpanContext extractedContext = tracer.extract(Format.Builtin.BINARY, carrier);
    assertEquals(contextToInject.getTraceId(), extractedContext.getTraceId());
    assertEquals(contextToInject.getSpanId(), extractedContext.getSpanId());
}
Also used : TestBinaryCarrier(io.jaegertracing.internal.propagation.TestBinaryCarrier) JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext)

Example 10 with JaegerSpanContext

use of io.jaegertracing.internal.JaegerSpanContext in project jaeger-client-java by jaegertracing.

the class ConfigurationTest method testPropagationBinary.

@Test
public void testPropagationBinary() {
    System.setProperty(Configuration.JAEGER_PROPAGATION, "jaeger");
    System.setProperty(Configuration.JAEGER_SERVICE_NAME, "Test");
    long traceIdLow = 1234L;
    long spanId = 5678L;
    TestBinaryCarrier buffer = new TestBinaryCarrier();
    JaegerSpanContext spanContext = new JaegerSpanContext(0, traceIdLow, spanId, 0, (byte) 0);
    JaegerTracer tracer = Configuration.fromEnv().getTracer();
    tracer.inject(spanContext, Format.Builtin.BINARY, buffer);
    JaegerSpanContext extractedContext = tracer.extract(Format.Builtin.BINARY, buffer);
    assertEquals(traceIdLow, extractedContext.getTraceIdLow());
    assertEquals(0, extractedContext.getTraceIdHigh());
    assertEquals(spanId, extractedContext.getSpanId());
}
Also used : TestBinaryCarrier(io.jaegertracing.internal.propagation.TestBinaryCarrier) JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext) JaegerTracer(io.jaegertracing.internal.JaegerTracer) 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