use of brave.messaging.MessagingRuleSampler 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.MessagingRuleSampler 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.MessagingRuleSampler 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.MessagingRuleSampler 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
}
Aggregations