Search in sources :

Example 66 with MutableSpan

use of brave.handler.MutableSpan in project brave by openzipkin.

the class ITSpringRabbitTracing method propagates_trace_info_across_amqp_from_producer.

@Test
public void propagates_trace_info_across_amqp_from_producer() {
    produceMessage();
    awaitMessageConsumed();
    MutableSpan producerSpan = producerSpanHandler.takeRemoteSpan(PRODUCER);
    assertThat(producerSpan.parentId()).isNull();
    MutableSpan consumerSpan = consumerSpanHandler.takeRemoteSpan(CONSUMER);
    assertChildOf(consumerSpan, producerSpan);
    MutableSpan listenerSpan = consumerSpanHandler.takeLocalSpan();
    assertChildOf(listenerSpan, consumerSpan);
}
Also used : MutableSpan(brave.handler.MutableSpan) Test(org.junit.Test)

Example 67 with MutableSpan

use of brave.handler.MutableSpan in project brave by openzipkin.

the class ITSpringRabbitTracing method creates_dependency_links.

@Test
public void creates_dependency_links() {
    produceMessage();
    awaitMessageConsumed();
    MutableSpan producerSpan = producerSpanHandler.takeRemoteSpan(PRODUCER);
    MutableSpan consumerSpan = consumerSpanHandler.takeRemoteSpan(CONSUMER);
    assertThat(producerSpan.localServiceName()).isEqualTo("producer");
    assertThat(producerSpan.remoteServiceName()).isEqualTo("rabbitmq");
    assertThat(consumerSpan.remoteServiceName()).isEqualTo("rabbitmq");
    assertThat(consumerSpan.localServiceName()).isEqualTo("consumer");
    consumerSpanHandler.takeLocalSpan();
}
Also used : MutableSpan(brave.handler.MutableSpan) Test(org.junit.Test)

Example 68 with MutableSpan

use of brave.handler.MutableSpan in project brave by openzipkin.

the class ITSpringRabbitTracing method traceContinuesToReply.

@Test
public void traceContinuesToReply() {
    produceUntracedMessage(TEST_EXCHANGE_REQUEST_REPLY, binding_request);
    awaitReplyMessageConsumed();
    MutableSpan requestConsumerSpan = consumerSpanHandler.takeRemoteSpan(CONSUMER);
    MutableSpan replyProducerSpan = consumerSpanHandler.takeRemoteSpan(PRODUCER);
    MutableSpan requestListenerSpan = consumerSpanHandler.takeLocalSpan();
    MutableSpan replyConsumerSpan = consumerSpanHandler.takeRemoteSpan(CONSUMER);
    MutableSpan replyListenerSpan = consumerSpanHandler.takeLocalSpan();
    assertThat(requestConsumerSpan.parentId()).isNull();
    assertThat(requestListenerSpan.parentId()).isEqualTo(requestConsumerSpan.id());
    assertThat(replyProducerSpan.parentId()).isEqualTo(requestListenerSpan.id());
    assertThat(replyConsumerSpan.parentId()).isEqualTo(replyProducerSpan.id());
    assertThat(replyListenerSpan.parentId()).isEqualTo(replyConsumerSpan.id());
    assertThat(Arrays.asList(requestListenerSpan, replyProducerSpan, replyConsumerSpan, replyListenerSpan)).extracting(MutableSpan::traceId).containsOnly(requestConsumerSpan.traceId());
}
Also used : MutableSpan(brave.handler.MutableSpan) Test(org.junit.Test)

Example 69 with MutableSpan

use of brave.handler.MutableSpan in project brave by openzipkin.

the class ITTracingFilter_Consumer method setsError_onUnimplemented.

@Test
public void setsError_onUnimplemented() {
    assertThatThrownBy(() -> wrongClient.get().sayHello("jorge")).isInstanceOf(RpcException.class);
    MutableSpan span = testSpanHandler.takeRemoteSpanWithErrorMessage(CLIENT, ".*Not found exported service.*");
    assertThat(span.tags()).containsEntry("dubbo.error_code", "1");
}
Also used : MutableSpan(brave.handler.MutableSpan) Test(org.junit.Test)

Example 70 with MutableSpan

use of brave.handler.MutableSpan in project brave by openzipkin.

the class IntegrationTestSpanHandler method doTakeSpan.

MutableSpan doTakeSpan(boolean flushed) {
    MutableSpan result;
    try {
        // Same rationale as ITRemote: tests should never take 5s in normal circumstances.
        // However, @SpringBootTest with web environment and a lot in the classpath can take >3s
        result = spans.poll(10, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new AssertionError(e);
    }
    assertThat(result).withFailMessage("Timeout waiting for span").isNotNull();
    assertThat(result.containsAnnotation("brave.flush")).withFailMessage("Orphaned span found: %s\n" + "Look for code missing span.flush() or span.finish().", result).isFalse();
    assertThat(result.startTimestamp()).withFailMessage("Expected a startTimestamp: %s\n" + "Look for code missing span.start().", result).isNotZero();
    if (flushed) {
        assertThat(result.finishTimestamp()).withFailMessage("Expected no finishTimestamp: %s", result).isZero();
    } else {
        assertThat(result.finishTimestamp()).withFailMessage("Expected a finishTimestamp: %s", result).isNotZero();
    }
    return result;
}
Also used : MutableSpan(brave.handler.MutableSpan)

Aggregations

MutableSpan (brave.handler.MutableSpan)141 Test (org.junit.Test)107 TraceContext (brave.propagation.TraceContext)36 KafkaStreams (org.apache.kafka.streams.KafkaStreams)28 StreamsBuilder (org.apache.kafka.streams.StreamsBuilder)28 Topology (org.apache.kafka.streams.Topology)28 Scope (brave.propagation.CurrentTraceContext.Scope)14 ProcessorContext (org.apache.kafka.streams.processor.ProcessorContext)12 KeyValue (org.apache.kafka.streams.KeyValue)9 ArrayList (java.util.ArrayList)8 ProducerRecord (org.apache.kafka.clients.producer.ProducerRecord)8 MessagingTracing (brave.messaging.MessagingTracing)7 FileNotFoundException (java.io.FileNotFoundException)7 Arrays (java.util.Arrays)7 List (java.util.List)7 CONSUMER (brave.Span.Kind.CONSUMER)6 PRODUCER (brave.Span.Kind.PRODUCER)6 SpanHandler (brave.handler.SpanHandler)6 KafkaTracing (brave.kafka.clients.KafkaTracing)6 KAFKA_STREAMS_FILTERED_TAG (brave.kafka.streams.KafkaStreamsTags.KAFKA_STREAMS_FILTERED_TAG)6