use of brave.messaging.MessagingTracing in project brave by openzipkin.
the class ITJms_1_1_TracingMessageProducer method customSampler.
@Test
public void customSampler() throws JMSException {
queueSender.close();
tracedQueueSession.close();
MessagingRuleSampler producerSampler = MessagingRuleSampler.newBuilder().putRule(channelNameEquals(jms.queue.getQueueName()), Sampler.NEVER_SAMPLE).build();
try (MessagingTracing messagingTracing = MessagingTracing.newBuilder(tracing).producerSampler(producerSampler).build()) {
// JMS 1.1 didn't have auto-closeable. tearDownTraced closes these
tracedQueueSession = JmsTracing.create(messagingTracing).queueConnection(jms.queueConnection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
queueSender = tracedQueueSession.createSender(jms.queue);
queueSender.send(message);
}
Message received = queueReceiver.receive();
assertThat(propertiesToMap(received)).containsKey("b3").satisfies(m -> assertThat(m.get("b3")).endsWith("-0"));
// @After will also check that the producer was not sampled
}
use of brave.messaging.MessagingTracing in project brave by openzipkin.
the class ITJms_2_0_TracingMessageProducer method customSampler.
@Test
public void customSampler() throws JMSException {
MessagingRuleSampler producerSampler = MessagingRuleSampler.newBuilder().putRule(channelNameEquals(jms.queue.getQueueName()), Sampler.NEVER_SAMPLE).build();
try (MessagingTracing messagingTracing = MessagingTracing.newBuilder(tracing).producerSampler(producerSampler).build();
JMSContext context = JmsTracing.create(messagingTracing).connectionFactory(((ArtemisJmsTestRule) jms).factory).createContext(JMSContext.AUTO_ACKNOWLEDGE)) {
context.createProducer().send(jms.queue, "foo");
}
Message received = queueReceiver.receive();
assertThat(propertiesToMap(received)).containsKey("b3").satisfies(m -> assertThat(m.get("b3")).endsWith("-0"));
// @After will also check that the producer was not sampled
}
use of brave.messaging.MessagingTracing in project brave by openzipkin.
the class ITJms_1_1_TracingMessageConsumer method receive_customSampler.
@Test
public void receive_customSampler() throws JMSException {
queueReceiver.close();
tracedSession.close();
MessagingRuleSampler consumerSampler = MessagingRuleSampler.newBuilder().putRule(channelNameEquals(jms.queue.getQueueName()), Sampler.NEVER_SAMPLE).build();
try (MessagingTracing messagingTracing = MessagingTracing.newBuilder(tracing).consumerSampler(consumerSampler).build()) {
// JMS 1.1 didn't have auto-closeable. tearDownTraced closes these
tracedQueueSession = JmsTracing.create(messagingTracing).queueConnection(jms.queueConnection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
messageConsumer = tracedQueueSession.createConsumer(jms.queue);
queueSender.send(message);
// Check that the message headers are not sampled
assertThat(messageConsumer.receive().getStringProperty("b3")).endsWith("-0");
}
// @After will also check that the consumer was not sampled
}
use of brave.messaging.MessagingTracing in project brave by openzipkin.
the class ITJms_2_0_TracingMessageConsumer method receive_customSampler.
@Test
public void receive_customSampler() throws JMSException {
queueReceiver.close();
MessagingRuleSampler consumerSampler = MessagingRuleSampler.newBuilder().putRule(channelNameEquals(jms.queue.getQueueName()), Sampler.NEVER_SAMPLE).build();
try (MessagingTracing messagingTracing = MessagingTracing.newBuilder(tracing).consumerSampler(consumerSampler).build();
JMSContext context = JmsTracing.create(messagingTracing).connectionFactory(((ArtemisJmsTestRule) jms).factory).createContext(JMSContext.AUTO_ACKNOWLEDGE);
JMSConsumer consumer = context.createConsumer(jms.queue)) {
queueSender.send(message);
// Check that the message headers are not sampled
assertThat(consumer.receive().getStringProperty("b3")).endsWith("-0");
}
// @After will also check that the consumer was not sampled
}
use of brave.messaging.MessagingTracing in project brave by openzipkin.
the class ITKafkaStreamsTracing method should_create_one_span_from_stream_input_topic_whenSharingEnabled.
@Test
public void should_create_one_span_from_stream_input_topic_whenSharingEnabled() {
String inputTopic = testName.getMethodName() + "-input";
StreamsBuilder builder = new StreamsBuilder();
builder.stream(inputTopic).foreach((k, v) -> {
});
Topology topology = builder.build();
MessagingTracing messagingTracing = MessagingTracing.create(tracing);
KafkaStreamsTracing kafkaStreamsTracing = KafkaStreamsTracing.newBuilder(messagingTracing).singleRootSpanOnReceiveBatch(true).build();
KafkaStreams streams = kafkaStreamsTracing.kafkaStreams(topology, streamsProperties());
send(new ProducerRecord<>(inputTopic, TEST_KEY, TEST_VALUE));
send(new ProducerRecord<>(inputTopic, TEST_KEY, TEST_VALUE));
send(new ProducerRecord<>(inputTopic, TEST_KEY, TEST_VALUE));
waitForStreamToRun(streams);
MutableSpan spanInput = testSpanHandler.takeRemoteSpan(CONSUMER);
assertThat(spanInput.tags()).containsEntry("kafka.topic", inputTopic);
streams.close();
streams.cleanUp();
}
Aggregations