Skip to content

Commit

Permalink
Support springcloud 3.1.x (#512)
Browse files Browse the repository at this point in the history
* support springcloud 2022

* support springcloud 2022

* support springcloud 2022

* update sofa common tools

---------

Co-authored-by: 致节 <hzj266771@antgroup.com>
  • Loading branch information
HzjNeverStop and 致节 committed Aug 3, 2023
1 parent 5bddb89 commit 76e0574
Show file tree
Hide file tree
Showing 37 changed files with 602 additions and 118 deletions.
23 changes: 8 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<parent>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofaboot-dependencies</artifactId>
<version>3.1.1</version>
<version>3.19.1</version>
</parent>

<artifactId>tracer-all-parent</artifactId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.3</version>
<packaging>pom</packaging>
<name>tracer-all-parent</name>
<description>Alipay SOFATracer Log Implemented by OpenTracing</description>
Expand All @@ -35,7 +35,6 @@
<module>sofa-tracer-plugins/sofa-tracer-rabbitmq-plugin</module>
<module>sofa-tracer-plugins/sofa-tracer-kafkamq-plugin</module>
<module>tracer-all</module>
<module>tracer-sofa-boot-starter</module>
<module>tracer-test/core-test</module>
<module>tracer-test/logback-test</module>
<module>tracer-test/log4j2-test</module>
Expand All @@ -51,6 +50,7 @@
<main.user.dir>${user.dir}</main.user.dir>
<maven.staging.plugin>1.6.7</maven.staging.plugin>
<maven.gpg.pluign>1.5</maven.gpg.pluign>
<spring-cloud.version>2021.0.7</spring-cloud.version>
</properties>

<licenses>
Expand Down Expand Up @@ -209,16 +209,10 @@

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>2.1.0.RELEASE</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
<version>2.1.0.RELEASE</version>
<scope>provided</scope>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
Expand All @@ -230,7 +224,7 @@
<dependency>
<groupId>com.alipay.sofa.common</groupId>
<artifactId>sofa-common-tools</artifactId>
<version>1.3.1</version>
<version>1.3.11</version>
</dependency>

<!-- 对外部框架的一些插件使用 -->
Expand Down Expand Up @@ -366,7 +360,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.compiler.source.version}</source>
<target>${java.compiler.target.version}</target>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-datasource-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.3</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
7 changes: 6 additions & 1 deletion sofa-tracer-plugins/sofa-tracer-dubbo-2.6.x-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.3</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -36,6 +36,11 @@
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<scope>test</scope>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.3</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-dubbo-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.3</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-flexible-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.3</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-httpclient-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.3</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-kafkamq-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.3</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.sofa.alipay.tracer.plugins.kafkamq.carrier.KafkaMqExtractCarrier;
import com.sofa.alipay.tracer.plugins.kafkamq.tracers.KafkaMQConsumeTracer;
import org.apache.kafka.clients.consumer.Consumer;
import org.apache.kafka.clients.consumer.ConsumerGroupMetadata;
import org.apache.kafka.clients.consumer.ConsumerRebalanceListener;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
Expand All @@ -41,6 +42,7 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.OptionalLong;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -176,6 +178,11 @@ public void seek(TopicPartition partition, long offset) {
consumer.seek(partition, offset);
}

@Override
public void seek(TopicPartition topicPartition, OffsetAndMetadata offsetAndMetadata) {
consumer.seek(topicPartition, offsetAndMetadata);
}

@Override
public void seekToBeginning(Collection<TopicPartition> partitions) {
consumer.seekToBeginning(partitions);
Expand Down Expand Up @@ -206,6 +213,17 @@ public OffsetAndMetadata committed(TopicPartition partition, Duration timeout) {
return consumer.committed(partition, timeout);
}

@Override
public Map<TopicPartition, OffsetAndMetadata> committed(Set<TopicPartition> set) {
return null;
}

@Override
public Map<TopicPartition, OffsetAndMetadata> committed(Set<TopicPartition> set,
Duration duration) {
return null;
}

@Override
public Map<MetricName, ? extends Metric> metrics() {
return consumer.metrics();
Expand Down Expand Up @@ -280,13 +298,23 @@ public Map<TopicPartition, Long> endOffsets(Collection<TopicPartition> partition
}

@Override
public void close() {
consumer.close();
public OptionalLong currentLag(TopicPartition topicPartition) {
return consumer.currentLag(topicPartition);
}

@Override
public void close(long timeout, TimeUnit unit) {
consumer.close(timeout, unit);
public ConsumerGroupMetadata groupMetadata() {
return consumer.groupMetadata();
}

@Override
public void enforceRebalance() {
consumer.enforceRebalance();
}

@Override
public void close() {
consumer.close();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.alipay.common.tracer.core.tracer.AbstractTracer;
import com.sofa.alipay.tracer.plugins.kafkamq.carrier.KafkaMqInjectCarrier;
import com.sofa.alipay.tracer.plugins.kafkamq.tracers.KafkaMQSendTracer;
import org.apache.kafka.clients.consumer.ConsumerGroupMetadata;
import org.apache.kafka.clients.consumer.OffsetAndMetadata;
import org.apache.kafka.clients.producer.Callback;
import org.apache.kafka.clients.producer.Producer;
Expand All @@ -39,11 +40,11 @@
import org.apache.kafka.common.errors.ProducerFencedException;
import org.apache.kafka.common.header.Headers;

import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

/**
* SofaTracerKafkaProducer.
Expand Down Expand Up @@ -87,6 +88,13 @@ public void sendOffsetsToTransaction(Map<TopicPartition, OffsetAndMetadata> offs
producer.sendOffsetsToTransaction(offsets, consumerGroupId);
}

@Override
public void sendOffsetsToTransaction(Map<TopicPartition, OffsetAndMetadata> map,
ConsumerGroupMetadata consumerGroupMetadata)
throws ProducerFencedException {
producer.sendOffsetsToTransaction(map, consumerGroupMetadata);
}

@Override
public void commitTransaction() throws ProducerFencedException {
producer.commitTransaction();
Expand Down Expand Up @@ -138,8 +146,8 @@ public void close() {
}

@Override
public void close(long timeout, TimeUnit timeUnit) {
producer.close(timeout, timeUnit);
public void close(Duration duration) {
producer.close(duration);
}

private void appendSpanTagsAndInject(ProducerRecord<K, V> producerRecord,
Expand Down
3 changes: 2 additions & 1 deletion sofa-tracer-plugins/sofa-tracer-mongodb-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.3</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand All @@ -27,6 +27,7 @@
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver</artifactId>
<version>3.8.2</version>
<scope>provided</scope>
</dependency>

Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-okhttp-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.3</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
7 changes: 6 additions & 1 deletion sofa-tracer-plugins/sofa-tracer-rabbitmq-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.3</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -48,6 +48,11 @@
<version>2.10.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.sofa.tracer.plugins.rabbitmq.base;

import com.sofa.alipay.tracer.plugins.rabbitmq.carrier.RabbitMqExtractCarrier;
import org.apache.commons.collections4.IteratorUtils;
import org.junit.Test;

import java.util.Collections;
Expand All @@ -40,15 +41,15 @@ public void testIterator() {
Map<String, Object> headers = Collections.singletonMap(key, value);
RabbitMqExtractCarrier carrier = new RabbitMqExtractCarrier(headers);
final Iterator<Map.Entry<String, String>> iterator = carrier.iterator();
assertThat(iterator).containsAll(map.entrySet());
assertThat(IteratorUtils.toList(iterator)).containsAll(map.entrySet());
}

@Test
public void testIterator_whenNullValue() {
Map<String, Object> headers = Collections.singletonMap("testSOFATracerId", null);
RabbitMqExtractCarrier carrier = new RabbitMqExtractCarrier(headers);
final Iterator<Map.Entry<String, String>> iterator = carrier.iterator();
assertThat(iterator).doesNotContainNull();
assertThat(IteratorUtils.toList(iterator)).doesNotContainNull();
}

@Test(expected = UnsupportedOperationException.class)
Expand Down
4 changes: 1 addition & 3 deletions sofa-tracer-plugins/sofa-tracer-redis-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.3</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand All @@ -28,7 +28,6 @@
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.1.9.RELEASE</version>
<scope>provided</scope>
</dependency>

Expand All @@ -47,7 +46,6 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>

Expand Down
Loading

0 comments on commit 76e0574

Please sign in to comment.