Search in sources :

Example 56 with MutableSpan

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

the class ITJms_1_1_TracingMessageConsumer method receive_resumesTrace.

void receive_resumesTrace(JMSRunnable send, MessageConsumer messageConsumer) throws JMSException {
    TraceContext parent = resetB3PropertyWithNewSampledContext(jms);
    send.run();
    Message received = messageConsumer.receive();
    MutableSpan consumerSpan = testSpanHandler.takeRemoteSpan(CONSUMER);
    assertChildOf(consumerSpan, parent);
    assertThat(received.getStringProperty("b3")).isEqualTo(parent.traceIdString() + "-" + consumerSpan.id() + "-1");
}
Also used : MutableSpan(brave.handler.MutableSpan) Message(javax.jms.Message) TextMessage(javax.jms.TextMessage) BytesMessage(javax.jms.BytesMessage) TraceContext(brave.propagation.TraceContext)

Example 57 with MutableSpan

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

the class ITJms_1_1_TracingMessageConsumer method messageListener_runsAfterConsumer.

void messageListener_runsAfterConsumer(JMSRunnable send, MessageConsumer messageConsumer) throws JMSException {
    messageConsumer.setMessageListener(m -> {
    });
    send.run();
    MutableSpan consumerSpan = testSpanHandler.takeRemoteSpan(CONSUMER);
    MutableSpan listenerSpan = testSpanHandler.takeLocalSpan();
    assertChildOf(listenerSpan, consumerSpan);
    assertSequential(consumerSpan, listenerSpan);
}
Also used : MutableSpan(brave.handler.MutableSpan)

Example 58 with MutableSpan

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

the class ITTracingJMSConsumer method messageListener_readsBaggage.

void messageListener_readsBaggage(Runnable send) {
    consumer.setMessageListener(m -> Tags.BAGGAGE_FIELD.tag(BAGGAGE_FIELD, tracing.tracer().currentSpan()));
    String baggage = "joey";
    producer.setProperty(BAGGAGE_FIELD_KEY, baggage);
    send.run();
    MutableSpan consumerSpan = testSpanHandler.takeRemoteSpan(CONSUMER);
    MutableSpan listenerSpan = testSpanHandler.takeLocalSpan();
    assertThat(consumerSpan.parentId()).isNull();
    assertChildOf(listenerSpan, consumerSpan);
    assertThat(listenerSpan.tags()).containsEntry(BAGGAGE_FIELD.name(), baggage);
}
Also used : MutableSpan(brave.handler.MutableSpan) MessageProperties.getPropertyIfString(brave.jms.MessageProperties.getPropertyIfString)

Example 59 with MutableSpan

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

the class ITTracingJMSConsumer method receive_startsNewTrace.

void receive_startsNewTrace(Runnable send) {
    send.run();
    consumer.receive();
    MutableSpan consumerSpan = testSpanHandler.takeRemoteSpan(CONSUMER);
    assertThat(consumerSpan.name()).isEqualTo("receive");
    assertThat(consumerSpan.tags()).containsEntry("jms.queue", jms.queueName);
}
Also used : MutableSpan(brave.handler.MutableSpan)

Example 60 with MutableSpan

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

the class ITTracingJMSConsumer method messageListener_runsAfterConsumer.

@Test
public void messageListener_runsAfterConsumer() {
    consumer.setMessageListener(m -> {
    });
    producer.send(jms.queue, "foo");
    MutableSpan consumerSpan = testSpanHandler.takeRemoteSpan(CONSUMER);
    MutableSpan listenerSpan = testSpanHandler.takeLocalSpan();
    assertChildOf(listenerSpan, consumerSpan);
    assertSequential(consumerSpan, listenerSpan);
}
Also used : MutableSpan(brave.handler.MutableSpan) Test(org.junit.Test)

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