use of com.uber.jaeger.SpanContext in project jaeger-client-java by jaegertracing.
the class ThriftSpanConverterTest method testRpcChildSpanHasTheSameId.
@Test
public void testRpcChildSpanHasTheSameId() {
String expectedOperation = "parent";
Span client = (Span) tracer.buildSpan(expectedOperation).withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT).startManual();
Map<String, String> map = new HashMap<>();
TextMap carrier = new TextMapInjectAdapter(map);
tracer.inject(client.context(), Format.Builtin.TEXT_MAP, carrier);
carrier = new TextMapExtractAdapter(map);
SpanContext ctx = (SpanContext) tracer.extract(Format.Builtin.TEXT_MAP, carrier);
assertEquals(client.context().getSpanId(), ctx.getSpanId());
Span server = (Span) tracer.buildSpan("child").withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER).asChildOf(ctx).startManual();
assertEquals("client and server must have the same span ID", client.context().getSpanId(), server.context().getSpanId());
}
use of com.uber.jaeger.SpanContext 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;
SpanContext ctx = setter.setBaggage(span, KEY, value);
assertBaggageLogs(span, KEY, null, false, false, false);
assertNull(ctx.getBaggageItem(KEY));
}
use of com.uber.jaeger.SpanContext 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";
SpanContext ctx = setter.setBaggage(span, KEY, value);
assertBaggageLogs(span, KEY, value, false, false, true);
assertNull(ctx.getBaggageItem(KEY));
assertEquals(1, metricsFactory.getCounter("jaeger:baggage_updates", "result=err"));
}
use of com.uber.jaeger.SpanContext 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";
SpanContext ctx = setter.setBaggage(span, KEY, value);
assertBaggageLogs(span, KEY, expected, true, false, false);
assertEquals(expected, ctx.getBaggageItem(KEY));
assertEquals(1, metricsFactory.getCounter("jaeger:baggage_truncations", ""));
assertEquals(1, metricsFactory.getCounter("jaeger:baggage_updates", "result=ok"));
}
use of com.uber.jaeger.SpanContext in project jaeger-client-java by jaegertracing.
the class JaegerThriftSpanConverterTest method testConvertSpanMixedReferences.
@Test
public void testConvertSpanMixedReferences() {
Span parent = tracer.buildSpan("foo").startManual();
Span parent2 = tracer.buildSpan("foo").startManual();
Span child = tracer.buildSpan("foo").addReference(References.FOLLOWS_FROM, parent.context()).asChildOf(parent2).startManual();
com.uber.jaeger.thriftjava.Span span = JaegerThriftSpanConverter.convertSpan((com.uber.jaeger.Span) child);
assertEquals(0, span.getParentSpanId());
assertEquals(2, span.getReferences().size());
assertEquals(buildReference((SpanContext) parent.context(), References.FOLLOWS_FROM), span.getReferences().get(0));
assertEquals(buildReference((SpanContext) parent2.context(), References.CHILD_OF), span.getReferences().get(1));
}
Aggregations