use of com.uber.jaeger.SpanContext in project jaeger-client-java by jaegertracing.
the class BaggageSetterTest method testUnsampledSpan.
@Test
public void testUnsampledSpan() {
tracer = new Tracer.Builder("SamplerTest", reporter, new ConstSampler(false)).withMetrics(metrics).build();
span = (Span) tracer.buildSpan("some-operation").startManual();
when(mgr.getRestriction(SERVICE, KEY)).thenReturn(Restriction.of(true, 5));
final String value = "value";
SpanContext ctx = setter.setBaggage(span, KEY, value);
assertEquals(value, ctx.getBaggageItem(KEY));
// No logs should be written if the span is not sampled
assertNull(span.getLogs());
}
use of com.uber.jaeger.SpanContext in project jaeger-client-java by jaegertracing.
the class B3TextMapCodecResiliencyTest method shouldFallbackWhenMaliciousInput.
@Test
@UseDataProvider("maliciousInputs")
public void shouldFallbackWhenMaliciousInput(String headerName, String maliciousInput) {
TextMap maliciousCarrier = validHeaders();
maliciousCarrier.put(headerName, maliciousInput);
// when
SpanContext extract = sut.extract(maliciousCarrier);
// then
assertNull(extract);
}
use of com.uber.jaeger.SpanContext in project jaeger-client-java by jaegertracing.
the class B3TextMapCodecTest method testInject.
@Test
public void testInject() throws Exception {
DelegatingTextMap textMap = new DelegatingTextMap();
b3Codec.inject(new SpanContext(1, 1, 1, SAMPLED), textMap);
assertTrue(textMap.containsKey(TRACE_ID_NAME));
assertTrue(textMap.containsKey(SPAN_ID_NAME));
}
use of com.uber.jaeger.SpanContext in project jaeger-client-java by jaegertracing.
the class B3TextMapCodecTest method downgrades128BitTraceIdToLower64Bits.
@Test
public void downgrades128BitTraceIdToLower64Bits() throws Exception {
String hex128Bits = "463ac35c9f6413ad48485a3953bb6124";
String lower64Bits = "48485a3953bb6124";
DelegatingTextMap textMap = new DelegatingTextMap();
textMap.put(TRACE_ID_NAME, hex128Bits);
textMap.put(SPAN_ID_NAME, lower64Bits);
textMap.put(PARENT_SPAN_ID_NAME, "0");
textMap.put(SAMPLED_NAME, "1");
textMap.put(FLAGS_NAME, "1");
SpanContext context = b3Codec.extract(textMap);
assertNotNull(HexCodec.lowerHexToUnsignedLong(lower64Bits));
assertEquals(HexCodec.lowerHexToUnsignedLong(lower64Bits).longValue(), context.getTraceId());
assertEquals(HexCodec.lowerHexToUnsignedLong(lower64Bits).longValue(), context.getSpanId());
assertEquals(0, context.getParentId());
assertEquals(SAMPLED_FLAG | DEBUG_FLAG, context.getFlags());
}
use of com.uber.jaeger.SpanContext in project jaeger-client-java by jaegertracing.
the class JaegerThriftSpanConverterTest method testConvertSpanTwoReferencesChildOf.
@Test
public void testConvertSpanTwoReferencesChildOf() {
Span parent = tracer.buildSpan("foo").startManual();
Span parent2 = tracer.buildSpan("foo").startManual();
Span child = tracer.buildSpan("foo").asChildOf(parent).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.CHILD_OF), span.getReferences().get(0));
assertEquals(buildReference((SpanContext) parent2.context(), References.CHILD_OF), span.getReferences().get(1));
}
Aggregations