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