use of brave.propagation.TraceContext in project brave by openzipkin.
the class HttpClientHandlerTest method handleSend_injectsTheTraceContext_onTheCarrier.
@Test
public void handleSend_injectsTheTraceContext_onTheCarrier() {
Object customCarrier = new Object();
TraceContext context = handler.handleSend(injector, customCarrier, request).context();
verify(injector).inject(context, customCarrier);
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class HttpClientHandlerTest method handleSend_injectsTheTraceContext.
@Test
public void handleSend_injectsTheTraceContext() {
TraceContext context = handler.handleSend(injector, request).context();
verify(injector).inject(context, request);
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class HttpServerHandlerTest method handleReceive_reusesTraceId.
@Test
public void handleReceive_reusesTraceId() {
HttpTracing httpTracing = HttpTracing.create(Tracing.newBuilder().supportsJoin(false).spanReporter(spans::add).build());
tracer = httpTracing.tracing().tracer();
handler = HttpServerHandler.create(httpTracing, adapter);
TraceContext incomingContext = tracer.nextSpan().context();
when(extractor.extract(request)).thenReturn(TraceContextOrSamplingFlags.create(incomingContext));
handler.handleReceive(extractor, request).finish();
assertThat(spans.get(0).shared()).isNull();
assertThat(spans.get(0).traceId()).isEqualTo(incomingContext.traceIdString());
assertThat(spans.get(0).parentId()).isEqualTo(HexCodec.toLowerHex(incomingContext.spanId()));
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class ITKafkaTracing method continues_a_trace_when_only_trace_id_propagated.
@Test
public void continues_a_trace_when_only_trace_id_propagated() throws Exception {
consumerTracing = KafkaTracing.create(Tracing.newBuilder().spanReporter(consumerSpans::add).propagationFactory(new Propagation.Factory() {
@Override
public <K> Propagation<K> create(Propagation.KeyFactory<K> keyFactory) {
return new TraceIdOnlyPropagation<>(keyFactory);
}
}).sampler(Sampler.ALWAYS_SAMPLE).build());
producerTracing = KafkaTracing.create(Tracing.newBuilder().spanReporter(producerSpans::add).propagationFactory(new Propagation.Factory() {
@Override
public <K> Propagation<K> create(Propagation.KeyFactory<K> keyFactory) {
return new TraceIdOnlyPropagation<>(keyFactory);
}
}).sampler(Sampler.ALWAYS_SAMPLE).build());
producer = createTracingProducer();
consumer = createTracingConsumer();
producer.send(new ProducerRecord<>(testName.getMethodName(), TEST_KEY, TEST_VALUE)).get();
ConsumerRecords<String, String> records = consumer.poll(10000);
assertThat(records).hasSize(1);
Span producerSpan = producerSpans.take();
Span consumerSpan = consumerSpans.take();
assertThat(producerSpan.traceId()).isEqualTo(consumerSpan.traceId());
for (ConsumerRecord<String, String> record : records) {
TraceContext forProcessor = consumerTracing.nextSpan(record).context();
assertThat(forProcessor.traceIdString()).isEqualTo(consumerSpan.traceId());
}
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class KafkaTracingTest method nextSpan_should_use_span_from_headers_as_parent.
@Test
public void nextSpan_should_use_span_from_headers_as_parent() {
addB3Headers(fakeRecord);
Span span = kafkaTracing.nextSpan(fakeRecord);
TraceContext context = span.context();
assertThat(HexCodec.toLowerHex(context.traceId())).isEqualTo(TRACE_ID);
assertThat(HexCodec.toLowerHex(context.parentId())).isEqualTo(SPAN_ID);
assertThat(context.sampled()).isEqualTo(true);
}
Aggregations