brave.messaging.MessagingTracing Java Examples
The following examples show how to use
brave.messaging.MessagingTracing.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MessagingTracingFactoryBeanTest.java From brave with Apache License 2.0 | 6 votes |
@Test public void customizers() { context = new XmlBeans("" + "<bean id=\"messagingTracing\" class=\"brave.spring.beans.MessagingTracingFactoryBean\">\n" + " <property name=\"tracing\">\n" + " <util:constant static-field=\"" + getClass().getName() + ".TRACING\"/>\n" + " </property>\n" + " <property name=\"customizers\">\n" + " <list>\n" + " <util:constant static-field=\"" + getClass().getName() + ".CUSTOMIZER_ONE\"/>\n" + " <util:constant static-field=\"" + getClass().getName() + ".CUSTOMIZER_TWO\"/>\n" + " </list>\n" + " </property>" + "</bean>" ); context.getBean("messagingTracing", MessagingTracing.class); verify(CUSTOMIZER_ONE).customize(any(MessagingTracing.Builder.class)); verify(CUSTOMIZER_TWO).customize(any(MessagingTracing.Builder.class)); }
Example #2
Source File: TraceMessagingAutoConfiguration.java From spring-cloud-sleuth with Apache License 2.0 | 6 votes |
@Bean @ConditionalOnMissingBean // NOTE: stable bean name as might be used outside sleuth MessagingTracing messagingTracing(Tracing tracing, @Nullable @ProducerSampler SamplerFunction<MessagingRequest> producerSampler, @Nullable @ConsumerSampler SamplerFunction<MessagingRequest> consumerSampler, @Nullable List<MessagingTracingCustomizer> messagingTracingCustomizers) { MessagingTracing.Builder builder = MessagingTracing.newBuilder(tracing); if (producerSampler != null) { builder.producerSampler(producerSampler); } if (consumerSampler != null) { builder.consumerSampler(consumerSampler); } if (messagingTracingCustomizers != null) { for (MessagingTracingCustomizer customizer : messagingTracingCustomizers) { customizer.customize(builder); } } return builder.build(); }
Example #3
Source File: ITJms_2_0_TracingMessageProducer.java From brave with Apache License 2.0 | 6 votes |
@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") // Check that the injected context was not sampled .satisfies(m -> assertThat(m.get("b3")).endsWith("-0")); // @After will also check that the producer was not sampled }
Example #4
Source File: ITJms_2_0_TracingMessageConsumer.java From brave with Apache License 2.0 | 6 votes |
@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 }
Example #5
Source File: ITTracingJMSProducer.java From brave with Apache License 2.0 | 6 votes |
@Test public void customSampler() throws JMSException { setupTracedProducer(JmsTracing.create(MessagingTracing.newBuilder(tracing) .producerSampler(MessagingRuleSampler.newBuilder() .putRule(channelNameEquals(jms.queue.getQueueName()), Sampler.NEVER_SAMPLE) .build()).build())); producer.send(jms.queue, "foo"); Message received = consumer.receive(); assertThat(propertiesToMap(received)) .containsAllEntriesOf(existingProperties) .containsKey("b3") // Check that the injected context was not sampled .satisfies(m -> assertThat(m.get("b3")).endsWith("-0")); // @After will also check that the producer was not sampled }
Example #6
Source File: ITJms_1_1_TracingMessageProducer.java From brave with Apache License 2.0 | 5 votes |
@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") // Check that the injected context was not sampled .satisfies(m -> assertThat(m.get("b3")).endsWith("-0")); // @After will also check that the producer was not sampled }
Example #7
Source File: MessagingTracingFactoryBeanTest.java From brave with Apache License 2.0 | 5 votes |
@Test public void consumerSampler() { context = new XmlBeans("" + "<bean id=\"messagingTracing\" class=\"brave.spring.beans.MessagingTracingFactoryBean\">\n" + " <property name=\"tracing\">\n" + " <util:constant static-field=\"" + getClass().getName() + ".TRACING\"/>\n" + " </property>\n" + " <property name=\"consumerSampler\">\n" + " <bean class=\"brave.sampler.SamplerFunctions\" factory-method=\"neverSample\"/>\n" + " </property>\n" + "</bean>" ); assertThat(context.getBean("messagingTracing", MessagingTracing.class).consumerSampler()) .isEqualTo(SamplerFunctions.neverSample()); }
Example #8
Source File: MessagingTracingFactoryBeanTest.java From brave with Apache License 2.0 | 5 votes |
@Test public void producerSampler() { context = new XmlBeans("" + "<bean id=\"messagingTracing\" class=\"brave.spring.beans.MessagingTracingFactoryBean\">\n" + " <property name=\"tracing\">\n" + " <util:constant static-field=\"" + getClass().getName() + ".TRACING\"/>\n" + " </property>\n" + " <property name=\"producerSampler\">\n" + " <bean class=\"brave.sampler.SamplerFunctions\" factory-method=\"neverSample\"/>\n" + " </property>\n" + "</bean>" ); assertThat(context.getBean("messagingTracing", MessagingTracing.class).producerSampler()) .isEqualTo(SamplerFunctions.neverSample()); }
Example #9
Source File: MessagingTracingFactoryBeanTest.java From brave with Apache License 2.0 | 5 votes |
@Test public void tracing() { context = new XmlBeans("" + "<bean id=\"messagingTracing\" class=\"brave.spring.beans.MessagingTracingFactoryBean\">\n" + " <property name=\"tracing\">\n" + " <util:constant static-field=\"" + getClass().getName() + ".TRACING\"/>\n" + " </property>\n" + "</bean>" ); assertThat(context.getBean("messagingTracing", MessagingTracing.class)) .extracting("tracing") .isEqualTo(TRACING); }
Example #10
Source File: MessagingTracingFactoryBean.java From brave with Apache License 2.0 | 5 votes |
@Override public MessagingTracing getObject() { MessagingTracing.Builder builder = MessagingTracing.newBuilder(tracing); if (producerSampler != null) builder.producerSampler(producerSampler); if (consumerSampler != null) builder.consumerSampler(consumerSampler); if (customizers != null) { for (MessagingTracingCustomizer customizer : customizers) customizer.customize(builder); } return builder.build(); }
Example #11
Source File: ITKafkaStreamsTracing.java From brave with Apache License 2.0 | 5 votes |
@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(); }
Example #12
Source File: ExampleTest.java From brave with Apache License 2.0 | 5 votes |
@Test public void showConstruction() { messagingTracing = MessagingTracing.newBuilder(tracing) .consumerSampler(MessagingRuleSampler.newBuilder() .putRule(channelNameEquals("alerts"), Sampler.NEVER_SAMPLE) .putRule(operationEquals("receive"), RateLimitingSampler.create(100)) .build()) .producerSampler(SamplerFunctions.neverSample()) .build(); }
Example #13
Source File: ITJms_1_1_TracingMessageConsumer.java From brave with Apache License 2.0 | 5 votes |
@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 }
Example #14
Source File: ITTracingJMSConsumer.java From brave with Apache License 2.0 | 5 votes |
@Test public void receive_customSampler() { setupTracedConsumer(JmsTracing.create(MessagingTracing.newBuilder(tracing) .consumerSampler(MessagingRuleSampler.newBuilder() .putRule(operationEquals("receive"), Sampler.NEVER_SAMPLE) .build()).build())); producer.send(jms.queue, "foo"); // Check that the message headers are not sampled assertThat(getPropertyIfString(consumer.receive(), "b3")) .endsWith("-0"); // @After will also check that the consumer was not sampled }
Example #15
Source File: TracingMethodMessageHandlerAdapter.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
TracingMethodMessageHandlerAdapter(MessagingTracing messagingTracing, Getter<MessageHeaderAccessor, String> getter) { this.tracing = messagingTracing.tracing(); this.tracer = tracing.tracer(); this.extractor = tracing.propagation().extractor(MessageConsumerRequest.GETTER); this.getter = getter; }
Example #16
Source File: TraceMessagingAutoConfiguration.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean SpringRabbitTracing springRabbitTracing(MessagingTracing messagingTracing, SleuthMessagingProperties properties) { return SpringRabbitTracing.newBuilder(messagingTracing) .remoteServiceName( properties.getMessaging().getRabbit().getRemoteServiceName()) .build(); }
Example #17
Source File: TraceMessagingAutoConfiguration.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean KafkaTracing kafkaTracing(MessagingTracing messagingTracing, SleuthMessagingProperties properties) { return KafkaTracing.newBuilder(messagingTracing) .remoteServiceName( properties.getMessaging().getKafka().getRemoteServiceName()) .build(); }
Example #18
Source File: TraceMessagingAutoConfigurationTests.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void configuresUserProvidedConsumerSampler() { contextRunner().withUserConfiguration(ConsumerSamplerConfig.class) .run((context) -> { SamplerFunction<MessagingRequest> consumerSampler = context .getBean(MessagingTracing.class).consumerSampler(); then(consumerSampler).isSameAs(ConsumerSamplerConfig.INSTANCE); }); }
Example #19
Source File: TraceMessagingAutoConfiguration.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean JmsTracing jmsTracing(MessagingTracing messagingTracing, SleuthMessagingProperties properties) { return JmsTracing.newBuilder(messagingTracing) .remoteServiceName( properties.getMessaging().getJms().getRemoteServiceName()) .build(); }
Example #20
Source File: TraceMessagingAutoConfigurationTests.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void defaultsToBraveProducerSampler() { contextRunner().run((context) -> { SamplerFunction<MessagingRequest> producerSampler = context .getBean(MessagingTracing.class).producerSampler(); then(producerSampler).isSameAs(SamplerFunctions.deferDecision()); }); }
Example #21
Source File: TraceMessagingAutoConfigurationTests.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void configuresUserProvidedProducerSampler() { contextRunner().withUserConfiguration(ProducerSamplerConfig.class) .run((context) -> { SamplerFunction<MessagingRequest> producerSampler = context .getBean(MessagingTracing.class).producerSampler(); then(producerSampler).isSameAs(ProducerSamplerConfig.INSTANCE); }); }
Example #22
Source File: TraceMessagingAutoConfigurationTests.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void defaultsToBraveConsumerSampler() { contextRunner().run((context) -> { SamplerFunction<MessagingRequest> consumerSampler = context .getBean(MessagingTracing.class).consumerSampler(); then(consumerSampler).isSameAs(SamplerFunctions.deferDecision()); }); }
Example #23
Source File: SpringRabbitTracing.java From brave with Apache License 2.0 | 4 votes |
/** @since 5.9 */ public static SpringRabbitTracing create(MessagingTracing messagingTracing) { return newBuilder(messagingTracing).build(); }
Example #24
Source File: MessagingTracingFactoryBean.java From brave with Apache License 2.0 | 4 votes |
@Override public Class<? extends MessagingTracing> getObjectType() { return MessagingTracing.class; }
Example #25
Source File: KafkaStreamsTracing.java From brave with Apache License 2.0 | 4 votes |
/** @since 5.10 */ public static Builder newBuilder(MessagingTracing messagingTracing) { return new Builder(KafkaTracing.create(messagingTracing)); }
Example #26
Source File: KafkaStreamsTracing.java From brave with Apache License 2.0 | 4 votes |
/** @since 5.10 */ public static KafkaStreamsTracing create(MessagingTracing messagingTracing) { return new Builder(KafkaTracing.create(messagingTracing)).build(); }
Example #27
Source File: SpringRabbitTracing.java From brave with Apache License 2.0 | 4 votes |
Builder(MessagingTracing messagingTracing) { if (messagingTracing == null) throw new NullPointerException("messagingTracing == null"); this.messagingTracing = messagingTracing; }
Example #28
Source File: SpringRabbitTracing.java From brave with Apache License 2.0 | 4 votes |
/** @since 5.9 */ public static Builder newBuilder(MessagingTracing messagingTracing) { return new Builder(messagingTracing); }
Example #29
Source File: SpringRabbitTracing.java From brave with Apache License 2.0 | 4 votes |
public static Builder newBuilder(Tracing tracing) { return newBuilder(MessagingTracing.create(tracing)); }
Example #30
Source File: JmsTracing.java From brave with Apache License 2.0 | 4 votes |
Builder(MessagingTracing messagingTracing) { if (messagingTracing == null) throw new NullPointerException("messagingTracing == null"); this.messagingTracing = messagingTracing; }