forked from sofastack/sofa-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tracer autoconfigure. (sofastack#847)
- Loading branch information
Showing
18 changed files
with
932 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...main/java/com/alipay/sofa/boot/autoconfigure/tracer/SofaTracerKafkaAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 | ||
* | ||
* http://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 com.alipay.sofa.boot.autoconfigure.tracer; | ||
|
||
import com.alipay.sofa.tracer.boot.kafka.processor.KafkaConsumerFactoryPostProcessor; | ||
import com.alipay.sofa.tracer.boot.kafka.processor.KafkaProducerFactoryPostProcessor; | ||
import com.sofa.alipay.tracer.plugins.kafkamq.aspect.KafkaListenerSofaTracerAspect; | ||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.EnableAspectJAutoProxy; | ||
import org.springframework.kafka.core.ConsumerFactory; | ||
import org.springframework.kafka.core.ProducerFactory; | ||
|
||
/** | ||
* @author chenchen6 2020/9/2 21:56 | ||
*/ | ||
@Configuration(proxyBeanMethods = false) | ||
@AutoConfigureAfter(KafkaAutoConfiguration.class) | ||
@ConditionalOnClass({ ProducerFactory.class, ConsumerFactory.class }) | ||
@EnableAspectJAutoProxy(proxyTargetClass = true) | ||
@ConditionalOnProperty(name = "com.alipay.tracer.kafka.enabled", havingValue = "true", matchIfMissing = true) | ||
public class SofaTracerKafkaAutoConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public KafkaConsumerFactoryPostProcessor kafkaConsumerFactoryPostProcessor() { | ||
return new KafkaConsumerFactoryPostProcessor(); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public KafkaProducerFactoryPostProcessor kafkaProducerFactoryPostProcessor() { | ||
return new KafkaProducerFactoryPostProcessor(); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public KafkaListenerSofaTracerAspect kafkaListenerSofaTracerAspect() { | ||
return new KafkaListenerSofaTracerAspect(); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...main/java/com/alipay/sofa/boot/autoconfigure/tracer/SofaTracerMongoAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 | ||
* | ||
* http://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 com.alipay.sofa.boot.autoconfigure.tracer; | ||
|
||
import com.alipay.sofa.tracer.boot.mongodb.SofaTracerMongoClientSettingsBuilderCustomizer; | ||
import com.mongodb.client.MongoClient; | ||
import org.springframework.boot.autoconfigure.AutoConfigureBefore; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* SofaTracerMongoAutoConfiguration | ||
* | ||
* @author linnan | ||
* @since 3.9.1 | ||
**/ | ||
@Configuration(proxyBeanMethods = false) | ||
@AutoConfigureBefore({ MongoAutoConfiguration.class }) | ||
@ConditionalOnClass({ MongoClient.class }) | ||
@ConditionalOnProperty(name = "com.alipay.tracer.mongodb.enabled", havingValue = "true", matchIfMissing = true) | ||
public class SofaTracerMongoAutoConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
SofaTracerMongoClientSettingsBuilderCustomizer sofaTracerMongoClientSettingsBuilderCustomizer() { | ||
return new SofaTracerMongoClientSettingsBuilderCustomizer(); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
.../main/java/com/alipay/sofa/boot/autoconfigure/tracer/SofaTracerRabbitMqConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 | ||
* | ||
* http://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 com.alipay.sofa.boot.autoconfigure.tracer; | ||
|
||
import com.alipay.sofa.tracer.boot.rabbitmq.processor.SofaTracerRabbitMqBeanPostProcessor; | ||
import com.sofa.alipay.tracer.plugins.rabbitmq.aspect.SofaTracerSendMessageAspect; | ||
import org.springframework.amqp.core.Message; | ||
import org.springframework.amqp.rabbit.core.RabbitTemplate; | ||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.EnableAspectJAutoProxy; | ||
|
||
/** | ||
* SofaTracerRabbitMqBeanPostProcessor. | ||
* | ||
* @author chenchen6 2020/8/09 20:44 | ||
* @since 3.1.0 | ||
*/ | ||
@Configuration(proxyBeanMethods = false) | ||
@AutoConfigureAfter(RabbitAutoConfiguration.class) | ||
@ConditionalOnClass({ Message.class, RabbitTemplate.class }) | ||
@ConditionalOnProperty(prefix = "com.alipay.sofa.tracer.rabbitmq", value = "enable", matchIfMissing = true) | ||
@EnableAspectJAutoProxy(proxyTargetClass = true) | ||
public class SofaTracerRabbitMqConfiguration { | ||
|
||
@ConditionalOnBean(RabbitTemplate.class) | ||
@Bean | ||
public SofaTracerSendMessageAspect rabbitMqSendTracingAspect(RabbitTemplate rabbitTemplate) { | ||
return new SofaTracerSendMessageAspect(rabbitTemplate.getExchange(), | ||
rabbitTemplate.getRoutingKey(), rabbitTemplate.getMessageConverter(), rabbitTemplate); | ||
} | ||
|
||
@ConditionalOnMissingBean | ||
@Bean | ||
public SofaTracerRabbitMqBeanPostProcessor sofaTracerRabbitMqBeanPostProcessor() { | ||
return new SofaTracerRabbitMqBeanPostProcessor(); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...src/main/java/com/alipay/sofa/boot/autoconfigure/tracer/SofaTracerRedisConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 | ||
* | ||
* http://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 com.alipay.sofa.boot.autoconfigure.tracer; | ||
|
||
import com.sofa.alipay.tracer.plugins.spring.redis.SofaTracerRCFBeanPostProcessor; | ||
import com.sofa.alipay.tracer.plugins.spring.redis.common.RedisActionWrapperHelper; | ||
|
||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
|
||
/** | ||
* @author guolei.sgl (guolei.sgl@antfin.com) 2019/11/19 8:03 PM | ||
* @since | ||
**/ | ||
@Configuration(proxyBeanMethods = false) | ||
@ConditionalOnClass({ RedisConnectionFactory.class, RedisActionWrapperHelper.class }) | ||
@ConditionalOnProperty(name = "com.alipay.sofa.tracer.redis.enabled", havingValue = "true", matchIfMissing = true) | ||
@AutoConfigureAfter(SofaTracerAutoConfiguration.class) | ||
public class SofaTracerRedisConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
RedisActionWrapperHelper redisActionWrapperHelper() { | ||
return new RedisActionWrapperHelper(); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
SofaTracerRCFBeanPostProcessor sofaTracerRCFBeanPostProcessor(RedisActionWrapperHelper redisActionWrapperHelper) { | ||
return new SofaTracerRCFBeanPostProcessor(redisActionWrapperHelper); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
.../main/java/com/alipay/sofa/boot/autoconfigure/tracer/SofaTracerRocketMqConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 | ||
* | ||
* http://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 com.alipay.sofa.boot.autoconfigure.tracer; | ||
|
||
import com.alipay.sofa.tracer.boot.rocketmq.processor.SofaTracerRocketMqConsumerPostProcessor; | ||
import com.alipay.sofa.tracer.boot.rocketmq.processor.SofaTracerRocketMqProducerPostProcessor; | ||
import org.apache.rocketmq.client.producer.MQProducer; | ||
import org.apache.rocketmq.spring.autoconfigure.RocketMQAutoConfiguration; | ||
import org.apache.rocketmq.spring.support.RocketMQListenerContainer; | ||
import org.springframework.boot.autoconfigure.AutoConfigureBefore; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* SofaTracerRabbitMqBeanPostProcessor. | ||
* | ||
* @author linnan | ||
* @since 3.9.1 | ||
*/ | ||
@Configuration(proxyBeanMethods = false) | ||
@AutoConfigureBefore(RocketMQAutoConfiguration.class) | ||
@ConditionalOnClass({ MQProducer.class, RocketMQListenerContainer.class }) | ||
@ConditionalOnProperty(prefix = "com.alipay.sofa.tracer.rocketmq", value = "enable", matchIfMissing = true) | ||
public class SofaTracerRocketMqConfiguration { | ||
|
||
@ConditionalOnMissingBean | ||
@Bean | ||
public SofaTracerRocketMqProducerPostProcessor sofaTracerRocketMqProducerPostProcessor() { | ||
return new SofaTracerRocketMqProducerPostProcessor(); | ||
} | ||
|
||
@ConditionalOnMissingBean | ||
@Bean | ||
public SofaTracerRocketMqConsumerPostProcessor sofaTracerRocketMqConsumerPostProcessor() { | ||
return new SofaTracerRocketMqConsumerPostProcessor(); | ||
} | ||
} |
Oops, something went wrong.