From 068099a4db5e60f0d496d46b2ab04c8bed1b4ee0 Mon Sep 17 00:00:00 2001 From: maciej-gromul <89904409+maciej-gromul@users.noreply.github.com> Date: Fri, 10 Mar 2023 08:57:28 +0100 Subject: [PATCH] =?UTF-8?q?Adding=20back=20for=20backwards=20compatibility?= =?UTF-8?q?=20deprecated=20TracingKafkaConsum=E2=80=A6=20(#2272)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kafka/TracingKafkaConsumerFactory.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 spring-cloud-sleuth-instrumentation/src/main/java/org/springframework/cloud/sleuth/instrument/kafka/TracingKafkaConsumerFactory.java diff --git a/spring-cloud-sleuth-instrumentation/src/main/java/org/springframework/cloud/sleuth/instrument/kafka/TracingKafkaConsumerFactory.java b/spring-cloud-sleuth-instrumentation/src/main/java/org/springframework/cloud/sleuth/instrument/kafka/TracingKafkaConsumerFactory.java new file mode 100644 index 000000000..50ee76873 --- /dev/null +++ b/spring-cloud-sleuth-instrumentation/src/main/java/org/springframework/cloud/sleuth/instrument/kafka/TracingKafkaConsumerFactory.java @@ -0,0 +1,52 @@ +/* + * Copyright 2013-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.sleuth.instrument.kafka; + +import org.apache.kafka.clients.consumer.Consumer; +import reactor.kafka.receiver.KafkaReceiver; +import reactor.kafka.receiver.ReceiverOptions; +import reactor.kafka.receiver.internals.ConsumerFactory; + +import org.springframework.beans.factory.BeanFactory; + +/** + * This decorates a Reactor Kafka {@link ConsumerFactory} to create decorated consumers of + * type {@link TracingKafkaConsumer}. This can be used by the {@link KafkaReceiver} + * factory methods to create instrumented receivers. + * + * @author Anders Clausen + * @author Flaviu Muresan + * @since 3.1.0 + * @deprecated Please use {@link TracingKafkaReceiver} that leverages + * {@link ReactiveKafkaTracingPropagator} + */ +@Deprecated +public class TracingKafkaConsumerFactory extends ConsumerFactory { + + private final BeanFactory beanFactory; + + public TracingKafkaConsumerFactory(BeanFactory beanFactory) { + super(); + this.beanFactory = beanFactory; + } + + @Override + public Consumer createConsumer(ReceiverOptions receiverOptions) { + return new TracingKafkaConsumer<>(super.createConsumer(receiverOptions), beanFactory); + } + +}