├── .github ├── ISSUE_TEMPLATE │ ├── Ask_Question.md │ └── Bug_Report.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── build.yml │ └── release.yml ├── .gitignore ├── CONTRIBUTING.md ├── Formatter.xml ├── HEADER ├── LICENSE ├── README.md ├── check_format.sh ├── codecov.yml ├── pom.xml ├── sofa-tracer-plugins ├── sofa-tracer-datasource-plugin │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── tracer │ │ │ └── plugins │ │ │ └── datasource │ │ │ ├── BaseDataSource.java │ │ │ ├── BasePreparedStatement.java │ │ │ ├── DBType.java │ │ │ ├── ExtendedConnection.java │ │ │ ├── ExtendedPreparedStatement.java │ │ │ ├── ExtendedStatement.java │ │ │ ├── Interceptor.java │ │ │ ├── Invocation.java │ │ │ ├── MethodRegistry.java │ │ │ ├── Prop.java │ │ │ ├── SmartDataSource.java │ │ │ ├── tracer │ │ │ ├── ConnectionTraceInterceptor.java │ │ │ ├── DataSourceClientDigestEncoder.java │ │ │ ├── DataSourceClientDigestJsonEncoder.java │ │ │ ├── DataSourceClientRequestCarrier.java │ │ │ ├── DataSourceClientStatJsonReporter.java │ │ │ ├── DataSourceClientStatReporter.java │ │ │ ├── DataSourceClientTracer.java │ │ │ ├── DataSourceLogEnum.java │ │ │ ├── DataSourceTracerKeys.java │ │ │ ├── DataSourceTracerState.java │ │ │ ├── Endpoint.java │ │ │ ├── KeyValueAnnotation.java │ │ │ └── StatementTracerInterceptor.java │ │ │ └── utils │ │ │ ├── DataSourceUtils.java │ │ │ └── SqlUtils.java │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── sofa │ │ │ └── tracer │ │ │ └── plugins │ │ │ └── datasource │ │ │ ├── C3p0Test.java │ │ │ ├── DataSourceUtilTest.java │ │ │ ├── DruidTest.java │ │ │ ├── OracleTnsTest.java │ │ │ ├── TestUtil.java │ │ │ ├── base │ │ │ ├── BaseTest.java │ │ │ └── FakeInterceptor.java │ │ │ └── bean │ │ │ ├── AbstractService.java │ │ │ ├── ConcreteClassService.java │ │ │ ├── InterfaceA.java │ │ │ └── InterfaceB.java │ │ └── resources │ │ └── mockito-extensions │ │ └── org.mockito.plugins.MockMaker ├── sofa-tracer-dubbo-2.6.x-plugin │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── alipay │ │ │ │ └── sofa │ │ │ │ └── tracer │ │ │ │ └── plugins │ │ │ │ └── dubbo │ │ │ │ ├── DubboSofaTracerFilter.java │ │ │ │ ├── constants │ │ │ │ └── AttachmentKeyConstants.java │ │ │ │ ├── encoder │ │ │ │ ├── DubboClientDigestEncoder.java │ │ │ │ ├── DubboClientDigestJsonEncoder.java │ │ │ │ ├── DubboServerDigestEncoder.java │ │ │ │ └── DubboServerDigestJsonEncoder.java │ │ │ │ ├── enums │ │ │ │ └── DubboLogEnum.java │ │ │ │ ├── stat │ │ │ │ ├── DubboClientStatJsonReporter.java │ │ │ │ ├── DubboClientStatReporter.java │ │ │ │ ├── DubboServerStatJsonReporter.java │ │ │ │ └── DubboServerStatReporter.java │ │ │ │ ├── tracer │ │ │ │ ├── DubboConsumerSofaTracer.java │ │ │ │ └── DubboProviderSofaTracer.java │ │ │ │ └── wrapper │ │ │ │ └── DataSizeCodecWrapper.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── dubbo │ │ │ ├── com.alibaba.dubbo.remoting.Codec2 │ │ │ └── com.alibaba.dubbo.rpc.Filter │ │ └── test │ │ └── java │ │ └── com │ │ └── alipay │ │ └── sofa │ │ └── tracer │ │ └── plugins │ │ └── dubbo │ │ ├── DubboSofaTracerTest.java │ │ ├── impl │ │ └── DubboServiceImpl.java │ │ └── service │ │ └── DubboService.java ├── sofa-tracer-dubbo-common-plugin │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── tracer │ │ │ └── plugins │ │ │ ├── dubbo │ │ │ ├── constants │ │ │ │ └── AttachmentKeyConstants.java │ │ │ ├── encoder │ │ │ │ ├── DubboClientDigestEncoder.java │ │ │ │ ├── DubboClientDigestJsonEncoder.java │ │ │ │ ├── DubboServerDigestEncoder.java │ │ │ │ └── DubboServerDigestJsonEncoder.java │ │ │ ├── enums │ │ │ │ └── DubboLogEnum.java │ │ │ ├── stat │ │ │ │ ├── DubboClientStatJsonReporter.java │ │ │ │ ├── DubboClientStatReporter.java │ │ │ │ ├── DubboServerStatJsonReporter.java │ │ │ │ └── DubboServerStatReporter.java │ │ │ └── tracer │ │ │ │ ├── DubboConsumerSofaTracer.java │ │ │ │ └── DubboProviderSofaTracer.java │ │ │ ├── dubbo26x │ │ │ ├── DubboSofaTracerFilter.java │ │ │ └── wrapper │ │ │ │ └── DataSizeCodecWrapper.java │ │ │ └── dubbo27x │ │ │ ├── DubboSofaTracerFilter.java │ │ │ └── wrapper │ │ │ └── DataSizeCodecWrapper.java │ │ └── resources │ │ └── META-INF │ │ └── dubbo │ │ ├── com.alibaba.dubbo.remoting.Codec2 │ │ ├── com.alibaba.dubbo.rpc.Filter │ │ ├── org.apache.dubbo.remoting.Codec2 │ │ └── org.apache.dubbo.rpc.Filter ├── sofa-tracer-dubbo-plugin │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── alipay │ │ │ │ └── sofa │ │ │ │ └── tracer │ │ │ │ └── plugins │ │ │ │ └── dubbo │ │ │ │ ├── DubboSofaTracerFilter.java │ │ │ │ ├── constants │ │ │ │ └── AttachmentKeyConstants.java │ │ │ │ ├── encoder │ │ │ │ ├── DubboClientDigestEncoder.java │ │ │ │ ├── DubboClientDigestJsonEncoder.java │ │ │ │ ├── DubboServerDigestEncoder.java │ │ │ │ └── DubboServerDigestJsonEncoder.java │ │ │ │ ├── enums │ │ │ │ └── DubboLogEnum.java │ │ │ │ ├── stat │ │ │ │ ├── DubboClientStatJsonReporter.java │ │ │ │ ├── DubboClientStatReporter.java │ │ │ │ ├── DubboServerStatJsonReporter.java │ │ │ │ └── DubboServerStatReporter.java │ │ │ │ ├── tracer │ │ │ │ ├── DubboConsumerSofaTracer.java │ │ │ │ └── DubboProviderSofaTracer.java │ │ │ │ └── wrapper │ │ │ │ └── DataSizeCodecWrapper.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── dubbo │ │ │ ├── com.alibaba.dubbo.remoting.Codec2 │ │ │ └── com.alibaba.dubbo.rpc.Filter │ │ └── test │ │ └── java │ │ └── com │ │ └── alipay │ │ └── sofa │ │ └── tracer │ │ └── plugins │ │ └── dubbo │ │ ├── DubboSofaTracerTest.java │ │ ├── impl │ │ └── DubboServiceImpl.java │ │ └── service │ │ └── DubboService.java ├── sofa-tracer-flexible-plugin │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── alipay │ │ └── sofa │ │ └── tracer │ │ └── plugin │ │ └── flexible │ │ ├── FlexibleDigestEncoder.java │ │ ├── FlexibleDigestJsonEncoder.java │ │ ├── FlexibleLogEnum.java │ │ ├── FlexibleStatJsonReporter.java │ │ ├── FlexibleStatReporter.java │ │ ├── FlexibleTracer.java │ │ └── annotations │ │ └── Tracer.java ├── sofa-tracer-httpclient-plugin │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── tracer │ │ │ └── plugins │ │ │ └── httpclient │ │ │ ├── HttpClientDigestEncoder.java │ │ │ ├── HttpClientDigestJsonEncoder.java │ │ │ ├── HttpClientLogEnum.java │ │ │ ├── HttpClientRequestCarrier.java │ │ │ ├── HttpClientStatJsonReporter.java │ │ │ ├── HttpClientStatReporter.java │ │ │ ├── HttpClientTracer.java │ │ │ ├── SofaTracerHttpClientBuilder.java │ │ │ └── interceptor │ │ │ ├── AbstractHttpRequestInterceptor.java │ │ │ ├── SofaTracerAsyncHttpInterceptor.java │ │ │ └── SofaTracerHttpInterceptor.java │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── tracer │ │ │ └── plugins │ │ │ └── httpclient │ │ │ ├── AsyncHttpClientTracerTest.java │ │ │ ├── HttpClientTracerTest.java │ │ │ ├── NonJsonTest.java │ │ │ ├── TestUtil.java │ │ │ └── base │ │ │ ├── AbstractTestBase.java │ │ │ ├── SpringBootWebApplication.java │ │ │ ├── client │ │ │ ├── HttpAsyncClientInstance.java │ │ │ └── HttpClientInstance.java │ │ │ └── controller │ │ │ ├── PostBody.java │ │ │ └── SampleRestController.java │ │ └── resources │ │ ├── application-non-json.properties │ │ ├── application.properties │ │ └── sofa.tracer.properties ├── sofa-tracer-kafkamq-plugin │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── sofa │ │ │ └── alipay │ │ │ └── tracer │ │ │ └── plugins │ │ │ └── kafkamq │ │ │ ├── aspect │ │ │ └── KafkaListenerSofaTracerAspect.java │ │ │ ├── carrier │ │ │ ├── KafkaMqExtractCarrier.java │ │ │ └── KafkaMqInjectCarrier.java │ │ │ ├── consumer │ │ │ └── SofaTracerKafkaConsumer.java │ │ │ ├── encoders │ │ │ ├── KafkaMQConsumeDigestEncoder.java │ │ │ ├── KafkaMQConsumeDigestJsonEncoder.java │ │ │ ├── KafkaMQSendDigestEncoder.java │ │ │ └── KafkaMQSendDigestJsonEncoder.java │ │ │ ├── enums │ │ │ └── KafkaMqLogEnum.java │ │ │ ├── factories │ │ │ ├── SofaTracerKafkaConsumerFactory.java │ │ │ └── SofaTracerKafkaProducerFactory.java │ │ │ ├── producer │ │ │ └── SofaTracerKafkaProducer.java │ │ │ ├── repoters │ │ │ ├── KafkaMQConsumeStatJsonReporter.java │ │ │ ├── KafkaMQConsumeStatReporter.java │ │ │ ├── KafkaMQSendStatJsonReporter.java │ │ │ └── KafkaMQSendStatReporter.java │ │ │ └── tracers │ │ │ ├── KafkaMQConsumeTracer.java │ │ │ └── KafkaMQSendTracer.java │ │ └── test │ │ └── java │ │ └── com │ │ └── sofa │ │ └── tracer │ │ └── plugins │ │ └── kafka │ │ └── base │ │ ├── MockKafkaExtractCarrier.java │ │ ├── MockKafkaInjectCarrier.java │ │ ├── MockSofaTracerConfiguration.java │ │ └── MockSofaTracerSpringKafkaTest.java ├── sofa-tracer-mongodb-plugin │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── alipay │ │ └── sofa │ │ └── tracer │ │ └── plugins │ │ └── mongodb │ │ ├── SofaTracerCommandListener.java │ │ ├── SofaTracerMongoClient.java │ │ ├── encodes │ │ ├── MongoDigestEncoder.java │ │ └── MongoDigestJsonEncoder.java │ │ ├── enums │ │ └── MongoClientLogEnum.java │ │ ├── repoters │ │ ├── MongoStatJsonReporter.java │ │ └── MongoStatReporter.java │ │ └── tracers │ │ └── MongoClientTracer.java ├── sofa-tracer-okhttp-plugin │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── alipay │ │ │ │ └── sofa │ │ │ │ └── tracer │ │ │ │ └── plugins │ │ │ │ └── okhttp │ │ │ │ ├── OkHttpDigestEncoder.java │ │ │ │ ├── OkHttpDigestJsonEncoder.java │ │ │ │ ├── OkHttpLogEnum.java │ │ │ │ ├── OkHttpRequestCarrier.java │ │ │ │ ├── OkHttpStatJsonReporter.java │ │ │ │ ├── OkHttpStatReporter.java │ │ │ │ ├── OkHttpTracer.java │ │ │ │ ├── SofaTracerOkHttpBuilder.java │ │ │ │ └── interceptor │ │ │ │ └── SofaTracerOkHttpInterceptor.java │ │ └── resources │ │ │ ├── application.properties │ │ │ └── sofa.tracer.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── alipay │ │ └── sofa │ │ └── tracer │ │ └── plugins │ │ └── okhttp │ │ └── base │ │ ├── OkHttpTracerNonJsonTest.java │ │ ├── OkHttpTracerTest.java │ │ ├── SpringBootWebApplication.java │ │ ├── client │ │ └── OkHttpClientInstance.java │ │ └── controller │ │ ├── PostBody.java │ │ └── SampleRestController.java ├── sofa-tracer-rabbitmq-plugin │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── sofa │ │ │ └── alipay │ │ │ └── tracer │ │ │ └── plugins │ │ │ └── rabbitmq │ │ │ ├── aspect │ │ │ └── SofaTracerSendMessageAspect.java │ │ │ ├── carrier │ │ │ ├── RabbitMqExtractCarrier.java │ │ │ └── RabbitMqInjectCarrier.java │ │ │ ├── encoders │ │ │ ├── RabbitMQConsumeDigestEncoder.java │ │ │ ├── RabbitMQConsumeDigestJsonEncoder.java │ │ │ ├── RabbitMQSendDigestEncoder.java │ │ │ └── RabbitMQSendDigestJsonEncoder.java │ │ │ ├── enums │ │ │ └── RabbitMqLogEnum.java │ │ │ ├── holder │ │ │ └── RabbitMqSofaTracerHolder.java │ │ │ ├── interceptor │ │ │ └── SofaTracerConsumeInterceptor.java │ │ │ ├── repoters │ │ │ ├── RabbitMQConsumeStatJsonReporter.java │ │ │ ├── RabbitMQConsumeStatReporter.java │ │ │ ├── RabbitMQSendStatJsonReporter.java │ │ │ └── RabbitMQSendStatReporter.java │ │ │ └── tracers │ │ │ ├── RabbitMQConsumeTracer.java │ │ │ └── RabbitMQSendTracer.java │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── sofa │ │ │ └── tracer │ │ │ └── plugins │ │ │ └── rabbitmq │ │ │ └── base │ │ │ ├── MockRabbitMqExtractCarrier.java │ │ │ ├── MockRabbitMqInjectCarrier.java │ │ │ ├── MockSofaTracerConfiguration.java │ │ │ ├── MockSofaTracerConsumeInterceptor.java │ │ │ └── MockSofaTracerSendMessageAspect.java │ │ └── resources │ │ └── application.properties ├── sofa-tracer-redis-plugin │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── sofa │ │ └── alipay │ │ └── tracer │ │ └── plugins │ │ └── spring │ │ └── redis │ │ ├── SofaTracerRCFBeanPostProcessor.java │ │ ├── TracingRedisConnectionFactory.java │ │ ├── common │ │ ├── Action.java │ │ ├── RedisActionWrapperHelper.java │ │ ├── RedisCommand.java │ │ ├── ThrowingAction.java │ │ └── ThrowingSupplier.java │ │ ├── connections │ │ ├── TracingReactiveRedisClusterConnection.java │ │ ├── TracingReactiveRedisConnection.java │ │ ├── TracingRedisClusterConnection.java │ │ ├── TracingRedisConnection.java │ │ └── TracingRedisSentinelConnection.java │ │ ├── encoder │ │ ├── RedisDigestEncoder.java │ │ └── RedisDigestJsonEncoder.java │ │ ├── enums │ │ └── RedisLogEnum.java │ │ ├── reporter │ │ ├── RedisStatJsonReporter.java │ │ └── RedisStatReporter.java │ │ └── tracer │ │ └── RedisSofaTracer.java ├── sofa-tracer-resttmplate-plugin │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── sofa │ │ │ └── alipay │ │ │ └── tracer │ │ │ └── plugins │ │ │ └── rest │ │ │ ├── RestTemplateDigestEncoder.java │ │ │ ├── RestTemplateDigestJsonEncoder.java │ │ │ ├── RestTemplateLogEnum.java │ │ │ ├── RestTemplateRequestCarrier.java │ │ │ ├── RestTemplateStatJsonReporter.java │ │ │ ├── RestTemplateStatReporter.java │ │ │ ├── RestTemplateTracer.java │ │ │ ├── SofaTracerRestTemplateBuilder.java │ │ │ └── interceptor │ │ │ ├── AsyncRestTemplateRequestInterceptor.java │ │ │ └── RestTemplateInterceptor.java │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── sofa │ │ │ └── tracer │ │ │ └── plugins │ │ │ └── resttemplate │ │ │ ├── AsyncRestTemplateTest.java │ │ │ ├── RestTemplateTest.java │ │ │ └── base │ │ │ ├── AbstractTestBase.java │ │ │ ├── PostBody.java │ │ │ ├── SampleRestController.java │ │ │ └── SpringBootWebApplication.java │ │ └── resources │ │ └── application.properties ├── sofa-tracer-rocketmq-plugin │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── alipay │ │ └── sofa │ │ └── tracer │ │ └── plugins │ │ └── rocketmq │ │ ├── encodes │ │ ├── RocketMQConsumeDigestEncoder.java │ │ ├── RocketMQConsumeDigestJsonEncoder.java │ │ ├── RocketMQSendDigestEncoder.java │ │ └── RocketMQSendDigestJsonEncoder.java │ │ ├── enums │ │ └── RocketMQLogEnum.java │ │ ├── interceptor │ │ ├── SofaTracerConsumeMessageHook.java │ │ └── SofaTracerSendMessageHook.java │ │ ├── repoters │ │ ├── RocketMQConsumeStatJsonReporter.java │ │ ├── RocketMQConsumeStatReporter.java │ │ ├── RocketMQSendStatJsonReporter.java │ │ └── RocketMQSendStatReporter.java │ │ └── tracers │ │ ├── RocketMQConsumeTracer.java │ │ └── RocketMQSendTracer.java ├── sofa-tracer-spring-cloud-plugin │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── alipay │ │ └── sofa │ │ └── tracer │ │ └── plugins │ │ └── springcloud │ │ ├── carriers │ │ └── FeignRequestHeadersCarrier.java │ │ ├── encodes │ │ ├── OpenFeignDigestEncoder.java │ │ └── OpenFeignDigestJsonEncoder.java │ │ ├── enums │ │ └── FeignClientLogEnum.java │ │ ├── instruments │ │ └── feign │ │ │ ├── SofaTracerFeignClient.java │ │ │ └── SofaTracerFeignContext.java │ │ ├── repoters │ │ ├── OpenFeignStatJsonReporter.java │ │ └── OpenFeignStatReporter.java │ │ └── tracers │ │ └── FeignClientTracer.java ├── sofa-tracer-springmessage-plugin │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── alipay │ │ └── sofa │ │ └── tracer │ │ └── plugins │ │ └── message │ │ ├── encodes │ │ ├── MessagePubDigestEncoder.java │ │ ├── MessagePubDigestJsonEncoder.java │ │ ├── MessageSubDigestEncoder.java │ │ └── MessageSubDigestJsonEncoder.java │ │ ├── enums │ │ └── SpringMessageLogEnum.java │ │ ├── interceptor │ │ └── SofaTracerChannelInterceptor.java │ │ ├── repoters │ │ ├── MessagePubStatJsonReporter.java │ │ ├── MessagePubStatReporter.java │ │ ├── MessageSubStatJsonReporter.java │ │ └── MessageSubStatReporter.java │ │ └── tracers │ │ ├── MessagePubTracer.java │ │ └── MessageSubTracer.java ├── sofa-tracer-springmvc-plugin │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── alipay │ │ └── sofa │ │ └── tracer │ │ └── plugins │ │ ├── springmvc │ │ ├── SpringMvcDigestEncoder.java │ │ ├── SpringMvcDigestJsonEncoder.java │ │ ├── SpringMvcHeadersCarrier.java │ │ ├── SpringMvcJsonStatReporter.java │ │ ├── SpringMvcLogEnum.java │ │ ├── SpringMvcSofaTracerFilter.java │ │ ├── SpringMvcStatReporter.java │ │ └── SpringMvcTracer.java │ │ └── webflux │ │ ├── SofaTraceableRequest.java │ │ ├── SofaTraceableResponse.java │ │ └── WebfluxSofaTracerFilter.java └── sofa-tracer-zipkin-plugin │ ├── pom.xml │ └── src │ ├── main │ └── java │ │ └── com │ │ └── alipay │ │ └── sofa │ │ └── tracer │ │ └── plugins │ │ └── zipkin │ │ ├── ZipkinSofaTracerRestTemplateCustomizer.java │ │ ├── ZipkinSofaTracerSpanRemoteReporter.java │ │ ├── adapter │ │ ├── NetUtils.java │ │ └── ZipkinV2SpanAdapter.java │ │ ├── initialize │ │ └── ZipkinReportRegisterBean.java │ │ ├── properties │ │ └── ZipkinProperties.java │ │ ├── reporters │ │ └── Okhttp3SpanRemoteReporter.java │ │ └── sender │ │ └── ZipkinRestTemplateSender.java │ └── test │ ├── java │ └── com │ │ └── alipay │ │ └── sofa │ │ └── tracer │ │ └── plugins │ │ └── zipkin │ │ ├── ZipkinReportRegisterBeanTest.java │ │ ├── ZipkinRestTemplateSenderTest.java │ │ ├── ZipkinSofaTracerSpanRemoteReporterTest.java │ │ └── ZipkinV2SpanAdapterTest.java │ └── resources │ ├── sofa.tracer.properties │ └── spring-bean.xml ├── tracer-all └── pom.xml ├── tracer-core ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── alipay │ │ │ ├── common │ │ │ └── tracer │ │ │ │ ├── core │ │ │ │ ├── SofaTracer.java │ │ │ │ ├── appender │ │ │ │ │ ├── TraceAppender.java │ │ │ │ │ ├── TracerLogRootDaemon.java │ │ │ │ │ ├── builder │ │ │ │ │ │ ├── JsonStringBuilder.java │ │ │ │ │ │ └── XStringBuilder.java │ │ │ │ │ ├── config │ │ │ │ │ │ └── LogReserveConfig.java │ │ │ │ │ ├── encoder │ │ │ │ │ │ └── SpanEncoder.java │ │ │ │ │ ├── file │ │ │ │ │ │ ├── AbstractRollingFileAppender.java │ │ │ │ │ │ ├── CompositeTraceAppender.java │ │ │ │ │ │ ├── LoadTestAwareAppender.java │ │ │ │ │ │ └── TimedRollingFileAppender.java │ │ │ │ │ ├── info │ │ │ │ │ │ └── StaticInfoLog.java │ │ │ │ │ ├── manager │ │ │ │ │ │ ├── AsyncCommonAppenderManager.java │ │ │ │ │ │ ├── AsyncCommonDigestAppenderManager.java │ │ │ │ │ │ ├── ConsumerExceptionHandler.java │ │ │ │ │ │ ├── ConsumerThreadFactory.java │ │ │ │ │ │ ├── ObjectEvent.java │ │ │ │ │ │ ├── SofaTracerSpanEvent.java │ │ │ │ │ │ ├── SofaTracerSpanEventFactory.java │ │ │ │ │ │ ├── StringConsumerExceptionHandler.java │ │ │ │ │ │ ├── StringEvent.java │ │ │ │ │ │ └── StringEventFactory.java │ │ │ │ │ └── self │ │ │ │ │ │ ├── SelfLog.java │ │ │ │ │ │ ├── SynchronizingSelfLog.java │ │ │ │ │ │ ├── Timestamp.java │ │ │ │ │ │ └── TracerDaemon.java │ │ │ │ ├── async │ │ │ │ │ ├── FunctionalAsyncSupport.java │ │ │ │ │ ├── SofaTracerBiConsumer.java │ │ │ │ │ ├── SofaTracerBiFunction.java │ │ │ │ │ ├── SofaTracerBiPredicate.java │ │ │ │ │ ├── SofaTracerBooleanSupplier.java │ │ │ │ │ ├── SofaTracerCallable.java │ │ │ │ │ ├── SofaTracerConsumer.java │ │ │ │ │ ├── SofaTracerDoubleBinaryOperator.java │ │ │ │ │ ├── SofaTracerDoubleConsumer.java │ │ │ │ │ ├── SofaTracerDoubleFunction.java │ │ │ │ │ ├── SofaTracerDoublePredicate.java │ │ │ │ │ ├── SofaTracerDoubleSupplier.java │ │ │ │ │ ├── SofaTracerDoubleToIntFunction.java │ │ │ │ │ ├── SofaTracerDoubleToLongFunction.java │ │ │ │ │ ├── SofaTracerDoubleUnaryOperator.java │ │ │ │ │ ├── SofaTracerFunction.java │ │ │ │ │ ├── SofaTracerIntBinaryOperator.java │ │ │ │ │ ├── SofaTracerIntConsumer.java │ │ │ │ │ ├── SofaTracerIntFunction.java │ │ │ │ │ ├── SofaTracerIntPredicate.java │ │ │ │ │ ├── SofaTracerIntSupplier.java │ │ │ │ │ ├── SofaTracerIntToDoubleFunction.java │ │ │ │ │ ├── SofaTracerIntToLongFunction.java │ │ │ │ │ ├── SofaTracerIntUnaryOperator.java │ │ │ │ │ ├── SofaTracerLongBinaryOperator.java │ │ │ │ │ ├── SofaTracerLongConsumer.java │ │ │ │ │ ├── SofaTracerLongFunction.java │ │ │ │ │ ├── SofaTracerLongPredicate.java │ │ │ │ │ ├── SofaTracerLongSupplier.java │ │ │ │ │ ├── SofaTracerLongToDoubleFunction.java │ │ │ │ │ ├── SofaTracerLongToIntFunction.java │ │ │ │ │ ├── SofaTracerLongUnaryOperator.java │ │ │ │ │ ├── SofaTracerObjDoubleConsumer.java │ │ │ │ │ ├── SofaTracerObjIntConsumer.java │ │ │ │ │ ├── SofaTracerObjLongConsumer.java │ │ │ │ │ ├── SofaTracerPredicate.java │ │ │ │ │ ├── SofaTracerRunnable.java │ │ │ │ │ ├── SofaTracerSupplier.java │ │ │ │ │ ├── SofaTracerToDoubleBiFunction.java │ │ │ │ │ ├── SofaTracerToDoubleFunction.java │ │ │ │ │ ├── SofaTracerToIntBiFunction.java │ │ │ │ │ ├── SofaTracerToIntFunction.java │ │ │ │ │ ├── SofaTracerToLongBiFunction.java │ │ │ │ │ ├── SofaTracerToLongFunction.java │ │ │ │ │ ├── TracedExecutorService.java │ │ │ │ │ └── TracerScheduleExecutorService.java │ │ │ │ ├── configuration │ │ │ │ │ ├── SofaTracerConfiguration.java │ │ │ │ │ └── SofaTracerExternalConfiguration.java │ │ │ │ ├── constants │ │ │ │ │ ├── ComponentNameConstants.java │ │ │ │ │ └── SofaTracerConstant.java │ │ │ │ ├── context │ │ │ │ │ ├── span │ │ │ │ │ │ └── SofaTracerSpanContext.java │ │ │ │ │ └── trace │ │ │ │ │ │ ├── SofaTraceContext.java │ │ │ │ │ │ └── SofaTracerThreadLocalTraceContext.java │ │ │ │ ├── exception │ │ │ │ │ ├── EmptyTracerStateStringException.java │ │ │ │ │ ├── SamplingStrategyErrorException.java │ │ │ │ │ ├── SofaTracerRuntimeException.java │ │ │ │ │ └── UnsupportedFormatException.java │ │ │ │ ├── extensions │ │ │ │ │ ├── SpanExtension.java │ │ │ │ │ └── SpanExtensionFactory.java │ │ │ │ ├── generator │ │ │ │ │ └── TraceIdGenerator.java │ │ │ │ ├── holder │ │ │ │ │ └── SofaTraceContextHolder.java │ │ │ │ ├── listener │ │ │ │ │ ├── SpanReportListener.java │ │ │ │ │ └── SpanReportListenerHolder.java │ │ │ │ ├── middleware │ │ │ │ │ └── parent │ │ │ │ │ │ └── AbstractDigestSpanEncoder.java │ │ │ │ ├── mock │ │ │ │ │ └── MockSofaTracer.java │ │ │ │ ├── registry │ │ │ │ │ ├── AbstractTextB3Formatter.java │ │ │ │ │ ├── AbstractTextFormatter.java │ │ │ │ │ ├── BinaryFormater.java │ │ │ │ │ ├── ExtendFormat.java │ │ │ │ │ ├── HttpHeadersB3Formatter.java │ │ │ │ │ ├── HttpHeadersFormatter.java │ │ │ │ │ ├── RegistryExtractorInjector.java │ │ │ │ │ ├── TextMapB3Formatter.java │ │ │ │ │ ├── TextMapFormatter.java │ │ │ │ │ └── TracerFormatRegistry.java │ │ │ │ ├── reporter │ │ │ │ │ ├── common │ │ │ │ │ │ ├── CommonSpanEncoder.java │ │ │ │ │ │ └── CommonTracerManager.java │ │ │ │ │ ├── composite │ │ │ │ │ │ └── SofaTracerCompositeDigestReporterImpl.java │ │ │ │ │ ├── digest │ │ │ │ │ │ ├── AbstractDiskReporter.java │ │ │ │ │ │ ├── DiskReporterImpl.java │ │ │ │ │ │ ├── event │ │ │ │ │ │ │ └── SpanEventDiskReporter.java │ │ │ │ │ │ └── manager │ │ │ │ │ │ │ └── SofaTracerDigestReporterAsyncManager.java │ │ │ │ │ ├── facade │ │ │ │ │ │ ├── AbstractReporter.java │ │ │ │ │ │ └── Reporter.java │ │ │ │ │ ├── stat │ │ │ │ │ │ ├── AbstractSofaTracerStatisticReporter.java │ │ │ │ │ │ ├── SofaTracerStatisticReporter.java │ │ │ │ │ │ ├── manager │ │ │ │ │ │ │ ├── SofaTracerStatisticReporterCycleTimesManager.java │ │ │ │ │ │ │ └── SofaTracerStatisticReporterManager.java │ │ │ │ │ │ └── model │ │ │ │ │ │ │ ├── StatKey.java │ │ │ │ │ │ │ ├── StatMapKey.java │ │ │ │ │ │ │ └── StatValues.java │ │ │ │ │ └── type │ │ │ │ │ │ └── TracerSystemLogEnum.java │ │ │ │ ├── samplers │ │ │ │ │ ├── Sampler.java │ │ │ │ │ ├── SamplerFactory.java │ │ │ │ │ ├── SamplerProperties.java │ │ │ │ │ ├── SamplingStatus.java │ │ │ │ │ └── SofaTracerPercentageBasedSampler.java │ │ │ │ ├── span │ │ │ │ │ ├── CommonLogSpan.java │ │ │ │ │ ├── CommonSpanTags.java │ │ │ │ │ ├── LogData.java │ │ │ │ │ ├── SofaTracerSpan.java │ │ │ │ │ ├── SofaTracerSpanReferenceRelationship.java │ │ │ │ │ └── SpanEventData.java │ │ │ │ ├── tags │ │ │ │ │ └── SpanTags.java │ │ │ │ ├── tracer │ │ │ │ │ ├── AbstractClientTracer.java │ │ │ │ │ ├── AbstractServerTracer.java │ │ │ │ │ └── AbstractTracer.java │ │ │ │ └── utils │ │ │ │ │ ├── AssertUtils.java │ │ │ │ │ ├── ByteArrayUtils.java │ │ │ │ │ ├── CommonUtils.java │ │ │ │ │ ├── DateUtils.java │ │ │ │ │ ├── ReflectionUtils.java │ │ │ │ │ ├── StringUtils.java │ │ │ │ │ └── TracerUtils.java │ │ │ │ └── util │ │ │ │ ├── CoolDown.java │ │ │ │ ├── DesensitizationHelper.java │ │ │ │ └── Desensitizer.java │ │ │ └── disruptor │ │ │ ├── AbstractSequencer.java │ │ │ ├── AggregateEventHandler.java │ │ │ ├── AlertException.java │ │ │ ├── BatchEventProcessor.java │ │ │ ├── BlockingWaitStrategy.java │ │ │ ├── BusySpinWaitStrategy.java │ │ │ ├── Cursored.java │ │ │ ├── DataProvider.java │ │ │ ├── EventFactory.java │ │ │ ├── EventHandler.java │ │ │ ├── EventPoller.java │ │ │ ├── EventProcessor.java │ │ │ ├── EventReleaseAware.java │ │ │ ├── EventReleaser.java │ │ │ ├── EventSequencer.java │ │ │ ├── EventSink.java │ │ │ ├── EventTranslator.java │ │ │ ├── EventTranslatorOneArg.java │ │ │ ├── EventTranslatorThreeArg.java │ │ │ ├── EventTranslatorTwoArg.java │ │ │ ├── EventTranslatorVararg.java │ │ │ ├── ExceptionHandler.java │ │ │ ├── FatalExceptionHandler.java │ │ │ ├── FixedSequenceGroup.java │ │ │ ├── IgnoreExceptionHandler.java │ │ │ ├── InsufficientCapacityException.java │ │ │ ├── LifecycleAware.java │ │ │ ├── LiteBlockingWaitStrategy.java │ │ │ ├── LiteTimeoutBlockingWaitStrategy.java │ │ │ ├── MultiProducerSequencer.java │ │ │ ├── NoOpEventProcessor.java │ │ │ ├── PhasedBackoffWaitStrategy.java │ │ │ ├── ProcessingSequenceBarrier.java │ │ │ ├── RingBuffer.java │ │ │ ├── Sequence.java │ │ │ ├── SequenceBarrier.java │ │ │ ├── SequenceGroup.java │ │ │ ├── SequenceGroups.java │ │ │ ├── SequenceReportingEventHandler.java │ │ │ ├── Sequenced.java │ │ │ ├── Sequencer.java │ │ │ ├── SingleProducerSequencer.java │ │ │ ├── SleepingWaitStrategy.java │ │ │ ├── TimeoutBlockingWaitStrategy.java │ │ │ ├── TimeoutException.java │ │ │ ├── TimeoutHandler.java │ │ │ ├── WaitStrategy.java │ │ │ ├── WorkHandler.java │ │ │ ├── WorkProcessor.java │ │ │ ├── WorkerPool.java │ │ │ ├── YieldingWaitStrategy.java │ │ │ ├── collections │ │ │ └── Histogram.java │ │ │ ├── dsl │ │ │ ├── BasicExecutor.java │ │ │ ├── ConsumerInfo.java │ │ │ ├── ConsumerRepository.java │ │ │ ├── Disruptor.java │ │ │ ├── EventHandlerGroup.java │ │ │ ├── EventProcessorFactory.java │ │ │ ├── EventProcessorInfo.java │ │ │ ├── ExceptionHandlerSetting.java │ │ │ ├── ExceptionHandlerWrapper.java │ │ │ ├── ProducerType.java │ │ │ └── WorkerPoolInfo.java │ │ │ └── util │ │ │ ├── DaemonThreadFactory.java │ │ │ └── Util.java │ └── resources │ │ └── tracer │ │ ├── log-codes.properties │ │ └── log-codes_zh_CN.properties │ └── test │ ├── java │ └── com │ │ └── alipay │ │ ├── common │ │ └── tracer │ │ │ ├── core │ │ │ ├── TestUtil.java │ │ │ ├── appender │ │ │ │ ├── LogCleanupTest.java │ │ │ │ ├── TracerLogRootDaemonLoggingpathTest.java │ │ │ │ ├── TracerLogRootDaemonTest.java │ │ │ │ ├── builder │ │ │ │ │ ├── JsonStringBuilderTest.java │ │ │ │ │ └── XStringBuilderTest.java │ │ │ │ ├── file │ │ │ │ │ ├── CompositeTraceAppenderTest.java │ │ │ │ │ └── TimedRollingFileAppenderTest.java │ │ │ │ ├── info │ │ │ │ │ └── StaticInfoLogTest.java │ │ │ │ ├── manager │ │ │ │ │ ├── ClientSpanEncoder.java │ │ │ │ │ ├── ConcurrentConsumerCorrectTest.java │ │ │ │ │ ├── ConcurrentDiscardTest.java │ │ │ │ │ ├── ConsumerExceptionHandlerTest.java │ │ │ │ │ ├── ManagerTestUtil.java │ │ │ │ │ └── StringConsumerExceptionHandlerTest.java │ │ │ │ └── self │ │ │ │ │ ├── SelfLogTest.java │ │ │ │ │ └── SynchronizingSelfLogTest.java │ │ │ ├── async │ │ │ │ ├── SofaTracerCallableTest.java │ │ │ │ ├── SofaTracerFunctionalTest.java │ │ │ │ ├── SofaTracerRunnableTest.java │ │ │ │ ├── TracedExecutorServiceTest.java │ │ │ │ └── TracerScheduleExecutorServiceTest.java │ │ │ ├── base │ │ │ │ └── AbstractTestBase.java │ │ │ ├── benchmark │ │ │ │ └── CountBenchmark.java │ │ │ ├── configuration │ │ │ │ └── SofaTracerConfigurationTest.java │ │ │ ├── context │ │ │ │ ├── span │ │ │ │ │ └── SofaTracerSpanContextTest.java │ │ │ │ └── trace │ │ │ │ │ └── SofaTracerThreadLocalTraceContextTest.java │ │ │ ├── exception │ │ │ │ ├── SamplingStrategyErrorExceptionTest.java │ │ │ │ ├── SofaTracerRuntimeExceptionTest.java │ │ │ │ └── UnsupportedFormatExceptionTest.java │ │ │ ├── holder │ │ │ │ └── SofaTraceContextHolderTest.java │ │ │ ├── listener │ │ │ │ └── SpanReportListenerHolderTest.java │ │ │ ├── mock │ │ │ │ └── MockSofaTracerTest.java │ │ │ ├── registry │ │ │ │ ├── BinaryFormaterTest.java │ │ │ │ ├── HttpHeadersB3FormatterTest.java │ │ │ │ ├── HttpHeadersFormatterTest.java │ │ │ │ ├── TextMapB3FormatterTest.java │ │ │ │ ├── TextMapFormatterTest.java │ │ │ │ └── TracerFormatRegistryTest.java │ │ │ ├── reporter │ │ │ │ ├── SofaTracerStatisticReporterCycleTimesManagerTest.java │ │ │ │ ├── common │ │ │ │ │ ├── CommonSpanEncoderTest.java │ │ │ │ │ └── CommonTracerManagerTest.java │ │ │ │ ├── composite │ │ │ │ │ └── SofaTracerCompositeDigestReporterImplTest.java │ │ │ │ ├── digest │ │ │ │ │ ├── DiskReporterImplTest.java │ │ │ │ │ ├── SofaTracerDigestReporterAsyncManagerTest.java │ │ │ │ │ └── event │ │ │ │ │ │ └── SpanEventDiskReporterTest.java │ │ │ │ └── stat │ │ │ │ │ ├── SofaTracerStatisticReporterImplTest.java │ │ │ │ │ └── model │ │ │ │ │ └── StatMapKeyTest.java │ │ │ ├── samplers │ │ │ │ ├── SamplerPropertiesTest.java │ │ │ │ ├── SamplingStatusTest.java │ │ │ │ └── SofaTracerPercentageBasedSamplerTest.java │ │ │ ├── span │ │ │ │ └── SofaTracerSpanTest.java │ │ │ ├── tracer │ │ │ │ ├── AbstractClientTracerTest.java │ │ │ │ └── AbstractServerTracerTest.java │ │ │ ├── tracertest │ │ │ │ ├── SofaTracerTest.java │ │ │ │ ├── encoder │ │ │ │ │ ├── ClientSpanEncoder.java │ │ │ │ │ ├── ClientSpanEventEncoder.java │ │ │ │ │ └── ServerSpanEncoder.java │ │ │ │ └── type │ │ │ │ │ └── TracerTestLogEnum.java │ │ │ └── utils │ │ │ │ ├── CommonUtilsTest.java │ │ │ │ ├── DateUtilsTest.java │ │ │ │ ├── StringUtilsTest.java │ │ │ │ └── TracerUtilsTest.java │ │ │ └── util │ │ │ ├── CoolDownTest.java │ │ │ ├── DesensitizationHelperTest.java │ │ │ └── MockDesensitizer.java │ │ └── disruptor │ │ ├── AggregateEventHandlerTest.java │ │ ├── BusySpinWaitStrategyTest.java │ │ ├── EventPollerTest.java │ │ ├── FixedSequenceGroupTest.java │ │ ├── IgnoreExceptionHandlerTest.java │ │ ├── LiteTimeoutBlockingWaitStrategyTest.java │ │ ├── PhasedBackoffWaitStrategyTest.java │ │ ├── SequenceGroupTest.java │ │ ├── SleepingWaitStrategyTest.java │ │ ├── TimeoutBlockingWaitStrategyTest.java │ │ ├── WorkerPoolTest.java │ │ ├── YieldingWaitStrategyTest.java │ │ ├── dsl │ │ └── WorkerPoolInfoTest.java │ │ └── support │ │ ├── DummyEventHandler.java │ │ ├── DummySequenceBarrier.java │ │ ├── SequenceUpdater.java │ │ ├── TestEvent.java │ │ └── WaitStrategyTestUtil.java │ └── resources │ └── sofa.tracer.properties ├── tracer-extensions ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── alipay │ │ └── common │ │ └── tracer │ │ └── extensions │ │ └── log │ │ ├── MDCSpanExtension.java │ │ └── constants │ │ └── MDCKeyConstants.java │ └── resources │ └── META-INF │ └── services │ └── com.alipay.common.tracer.core.extensions.SpanExtension ├── tracer-sofa-boot-starter ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── alipay │ │ │ └── sofa │ │ │ └── tracer │ │ │ └── boot │ │ │ ├── configuration │ │ │ └── SofaTracerAutoConfiguration.java │ │ │ ├── datasource │ │ │ ├── configuration │ │ │ │ └── SofaTracerDataSourceAutoConfiguration.java │ │ │ ├── processor │ │ │ │ ├── DataSourceBeanFactoryPostProcessor.java │ │ │ │ └── DataSourceBeanPostProcessor.java │ │ │ └── properties │ │ │ │ └── SofaTracerDataSourceProperties.java │ │ │ ├── flexible │ │ │ ├── aop │ │ │ │ ├── SofaTracerAdvisingBeanPostProcessor.java │ │ │ │ ├── TracerAnnotationClassAdvisor.java │ │ │ │ └── TracerAnnotationClassPointcut.java │ │ │ ├── configuration │ │ │ │ └── TracerAnnotationConfiguration.java │ │ │ └── processor │ │ │ │ ├── MethodInvocationProcessor.java │ │ │ │ ├── SofaTracerIntroductionInterceptor.java │ │ │ │ └── SofaTracerMethodInvocationProcessor.java │ │ │ ├── kafka │ │ │ ├── configuration │ │ │ │ └── SofaTracerKafkaAutoConfiguration.java │ │ │ └── processor │ │ │ │ ├── KafkaConsumerFactoryPostProcessor.java │ │ │ │ └── KafkaProducerFactoryPostProcessor.java │ │ │ ├── listener │ │ │ └── SofaTracerConfigurationListener.java │ │ │ ├── message │ │ │ ├── configuration │ │ │ │ └── SpringMessageAutoConfiguration.java │ │ │ └── processor │ │ │ │ └── StreamRocketMQTracerBeanPostProcessor.java │ │ │ ├── mongodb │ │ │ ├── configuration │ │ │ │ └── SofaTracerMongoAutoConfiguration.java │ │ │ └── processor │ │ │ │ └── SofaTracerMongoDbPostProcessor.java │ │ │ ├── properties │ │ │ └── SofaTracerProperties.java │ │ │ ├── rabbitmq │ │ │ ├── configuration │ │ │ │ └── SofaTracerRabbitMqConfiguration.java │ │ │ └── processor │ │ │ │ └── SofaTracerRabbitMqBeanPostProcessor.java │ │ │ ├── redis │ │ │ ├── configuration │ │ │ │ └── SofaTracerRedisConfiguration.java │ │ │ └── package-info.java │ │ │ ├── resttemplate │ │ │ ├── SofaTracerRestTemplateConfiguration.java │ │ │ ├── SofaTracerRestTemplateEnhance.java │ │ │ └── processor │ │ │ │ └── SofaTracerRestTemplateBeanPostProcessor.java │ │ │ ├── springcloud │ │ │ ├── configuration │ │ │ │ └── SofaTracerFeignClientAutoConfiguration.java │ │ │ ├── processor │ │ │ │ └── SofaTracerFeignContextBeanPostProcessor.java │ │ │ └── properties │ │ │ │ └── SofaTracerMessagingProperties.java │ │ │ ├── springmvc │ │ │ ├── configuration │ │ │ │ └── OpenTracingSpringMvcAutoConfiguration.java │ │ │ └── properties │ │ │ │ └── OpenTracingSpringMvcProperties.java │ │ │ └── zipkin │ │ │ ├── configuration │ │ │ └── ZipkinSofaTracerAutoConfiguration.java │ │ │ └── properties │ │ │ ├── ZipkinSofaTracerProperties.java │ │ │ └── ZipkinSofaTracerSamplerProperties.java │ └── resources │ │ └── META-INF │ │ └── spring.factories │ └── test │ ├── java │ └── com │ │ └── alipay │ │ └── sofa │ │ └── tracer │ │ └── boot │ │ ├── TestUtil.java │ │ ├── base │ │ ├── AbstractTestBase.java │ │ ├── AbstractTestCloudBase.java │ │ ├── ConfigurationHolder.java │ │ ├── ConfigurationHolderListener.java │ │ ├── DatasourceBeanDefinitionRegistry.java │ │ ├── HikariDataSourceConfiguration.java │ │ ├── SpringBootWebApplication.java │ │ └── controller │ │ │ ├── SampleRestController.java │ │ │ └── TestService.java │ │ ├── config │ │ └── ConfigurationTest.java │ │ ├── datasource │ │ ├── DataSourceBFPPTest.java │ │ ├── DataSourceTracerDisableTest.java │ │ ├── DataSourceTracerTest.java │ │ └── DataSourceUrlTest.java │ │ ├── flexible │ │ ├── FlexibleReporterTest.java │ │ ├── FlexibleTracerTest.java │ │ └── TestReporter.java │ │ ├── opentracing │ │ └── profiles │ │ │ ├── init │ │ │ └── InitProfileTracerTest.java │ │ │ └── tracer │ │ │ └── OpenTracingTest.java │ │ ├── redis │ │ └── SofaTracerRedisConnectionTest.java │ │ ├── resttemplate │ │ └── TestRestTemplateRibbon.java │ │ ├── springcloud │ │ └── FeignClientTest.java │ │ ├── springmvc │ │ ├── SpringMvcAsyncTest.java │ │ ├── SpringMvcFilterJsonOutputTest.java │ │ ├── SpringMvcFilterTest.java │ │ └── WebFluxTracerTest.java │ │ └── zipkin │ │ ├── ZipkinSofaTracerSpanRemoteReporterTest.java │ │ └── mock │ │ └── MockAbstractTracer.java │ └── resources │ ├── META-INF │ └── spring.factories │ ├── application-async.properties │ ├── application-config.properties │ ├── application-configerror.properties │ ├── application-datasource.properties │ ├── application-feign.properties │ ├── application-flexible.properties │ ├── application-init.properties │ ├── application-json.properties │ ├── application-non-json.properties │ ├── application-redis.properties │ ├── application-ribbon.properties │ ├── application-tracer.properties │ ├── application-zipkin.properties │ ├── application.properties │ └── hikariDataSource.xml └── tracer-test ├── core-test ├── pom.xml └── src │ └── test │ ├── java │ └── com │ │ └── alipay │ │ └── common │ │ └── tracer │ │ └── test │ │ ├── MDCMultiThreadTest.java │ │ ├── MDCTest.java │ │ ├── TestUtil.java │ │ ├── base │ │ └── AbstractTestBase.java │ │ ├── core │ │ └── sofatracer │ │ │ ├── SofaTracerDemoTest.java │ │ │ ├── SofaTracerStatisticsDemoTest.java │ │ │ ├── encoder │ │ │ ├── ClientSpanEncoder.java │ │ │ └── ServerSpanEncoder.java │ │ │ └── type │ │ │ └── TracerTestLogEnum.java │ │ └── demo │ │ └── DemoTracerTest.java │ └── resources │ └── log4j.xml ├── log4j-test ├── pom.xml └── src │ └── test │ ├── java │ └── com │ │ └── alipay │ │ └── common │ │ └── tracer │ │ └── LogTest.java │ └── resources │ └── log4j.properties ├── log4j2-test ├── pom.xml └── src │ └── test │ ├── java │ └── com │ │ └── alipay │ │ └── common │ │ └── tracer │ │ └── LogTest.java │ └── resources │ └── log4j2.xml └── logback-test ├── pom.xml └── src └── test ├── java └── com │ └── alipay │ └── commom │ └── tracer │ └── LogTest.java └── resources └── logback.xml /.github/ISSUE_TEMPLATE/Ask_Question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Ask Question 3 | about: Ask a question about usage or feature 4 | 5 | --- 6 | 7 | ### Your question 8 | 9 | describe your question clearly 10 | 11 | ### Your scenes 12 | 13 | describe your use scenes (why need this feature) 14 | 15 | ### Your advice 16 | 17 | describe the advice or solution you'd like 18 | 19 | ### Environment 20 | 21 | - SOFATracer version: 22 | - JVM version (e.g. `java -version`): 23 | - OS version (e.g. `uname -a`): 24 | - Maven version: 25 | - IDE version: 26 | 27 | 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Bug_Report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | ### Describe the bug 8 | 9 | A clear and concise description of what the bug is. 10 | 11 | ### Expected behavior 12 | 13 | ### Actual behavior 14 | 15 | ### Steps to reproduce 16 | 17 | ### Minimal yet complete reproducer code (or GitHub URL to code) 18 | 19 | ### Environment 20 | 21 | - SOFATracer version: 22 | - JVM version (e.g. `java -version`): 23 | - OS version (e.g. `uname -a`): 24 | - Maven version: 25 | - IDE version: 26 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Motivation: 2 | 3 | Explain the context, and why you're making that change. 4 | To make others understand what is the problem you're trying to solve. 5 | 6 | ### Modification: 7 | 8 | Describe the idea and modifications you've done. 9 | 10 | ### Result: 11 | 12 | Fixes #. 13 | 14 | If there is no issue then describe the changes introduced by this PR. 15 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | # This workflow will build a Java project with Maven 19 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven 20 | 21 | name: build 22 | 23 | on: 24 | push: 25 | branches: [ master ] 26 | pull_request: 27 | branches: [ master ] 28 | 29 | jobs: 30 | build: 31 | 32 | runs-on: ubuntu-latest 33 | 34 | steps: 35 | - uses: actions/checkout@v2 36 | with: 37 | fetch-depth: 2 38 | - name: Set up JDK 1.8 39 | uses: actions/setup-java@v1 40 | with: 41 | java-version: 1.8 42 | - name: Build with Maven 43 | run: mvn clean install -DskipTests -B -V 44 | && sh ./check_format.sh 45 | && mvn clean test 46 | - name: Codecov 47 | uses: codecov/codecov-action@v1 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | bin 3 | bak 4 | .pmd 5 | .project 6 | .settings 7 | .classpath 8 | .idea.xml 9 | .idea 10 | *.class 11 | *.bak 12 | *.iml 13 | *.ipr 14 | *.iws 15 | .DS_Store 16 | nb-configuration.xml 17 | coverage-report 18 | logs 19 | *.log 20 | pom.xml.versionsBackup -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing to SOFATracer 2 | 3 | SOFATracer is released under the Apache 2.0 license, and follows a very 4 | standard Github development process, using Github tracker for issues and 5 | merging pull requests into master . If you would like to contribute something, 6 | or simply want to hack on the code this document should help you get started. 7 | 8 | ### Sign the Contributor License Agreement 9 | Before we accept a non-trivial patch or pull request we will need you to 10 | sign the Contributor License Agreement. Signing the contributor’s agreement 11 | does not grant anyone commit rights to the main repository, but it does mean 12 | that we can accept your contributions, and you will get an author credit if 13 | we do. Active contributors might be asked to join the core team, and given 14 | the ability to merge pull requests. 15 | 16 | ### Code Conventions 17 | None of these is essential for a pull request, but they will all help. 18 | 19 | 1. we provided a [code formatter file](./Formatter.xml), it will formatting 20 | automatically your project when during process of building. 21 | 22 | 2. Make sure all new `.java` files to have a simple Javadoc class comment 23 | with at least an `@author` tag identifying you, and preferably at least a 24 | paragraph on what the class is for. 25 | 26 | 3. Add the ASF license header comment to all new `.java` files (copy from existing files in the project) 27 | 28 | 4. Add yourself as an `@author` to the `.java` files that you modify substantially (more than cosmetic changes). 29 | 30 | 5. Add some Javadocs. 31 | 32 | 6. A few unit tests would help a lot as well — someone has to do it. 33 | 34 | 7. When writing a commit message please follow [these conventions](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), if 35 | you are fixing an existing issue please add Fixes gh-XXXX at the end 36 | of the commit message (where XXXX is the issue number). -------------------------------------------------------------------------------- /HEADER: -------------------------------------------------------------------------------- 1 | Licensed to the Apache Software Foundation (ASF) under one or more 2 | contributor license agreements. See the NOTICE file distributed with 3 | this work for additional information regarding copyright ownership. 4 | The ASF licenses this file to You under the Apache License, Version 2.0 5 | (the "License"); you may not use this file except in compliance with 6 | the License. You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | -------------------------------------------------------------------------------- /check_format.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | BASEDIR=$(dirname $0) 4 | 5 | cd ${BASEDIR} 6 | 7 | # make sure git has no un commit files 8 | if [ -n "$(git status --untracked-files=no --porcelain)" ]; then 9 | echo "Please commit your change before run this shell, un commit files:" 10 | git status --untracked-files=no --porcelain 11 | exit -1 12 | fi -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - "pom.xml" -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-datasource-plugin/src/main/java/com/alipay/sofa/tracer/plugins/datasource/Interceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.datasource; 18 | 19 | /** 20 | * @author shusong.yss 21 | * @author qilong.zql 22 | * @since 2.2.0 23 | */ 24 | public interface Interceptor { 25 | 26 | /** 27 | * execute interceptor chain 28 | * @param chain 29 | * @return 30 | * @throws Exception 31 | */ 32 | Object intercept(Chain chain) throws Exception; 33 | 34 | interface Chain { 35 | 36 | Object proceed() throws Exception; 37 | 38 | String getOriginalSql(); 39 | 40 | String getProcessingSql(); 41 | 42 | void setProcessingSql(String processingSql); 43 | 44 | BaseDataSource getDataSource(); 45 | 46 | ExtendedConnection getConnection(); 47 | 48 | ExtendedStatement getStatement(); 49 | 50 | boolean hasNext(); 51 | 52 | Interceptor next(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-datasource-plugin/src/main/java/com/alipay/sofa/tracer/plugins/datasource/tracer/DataSourceClientRequestCarrier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.datasource.tracer; 18 | 19 | import io.opentracing.propagation.TextMap; 20 | 21 | import java.util.Iterator; 22 | import java.util.LinkedHashMap; 23 | import java.util.Map; 24 | 25 | /** 26 | * @author shusong.yss 27 | * @author qilong.zql 28 | * @since 2.2.0 29 | */ 30 | public class DataSourceClientRequestCarrier implements TextMap { 31 | 32 | private final Map tagsWithStr = new LinkedHashMap(); 33 | 34 | @Override 35 | public Iterator> iterator() { 36 | return tagsWithStr.entrySet().iterator(); 37 | } 38 | 39 | @Override 40 | public void put(String key, String value) { 41 | tagsWithStr.put(key, value); 42 | } 43 | } -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-datasource-plugin/src/main/java/com/alipay/sofa/tracer/plugins/datasource/tracer/DataSourceTracerKeys.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.datasource.tracer; 18 | 19 | /** 20 | * @author shusong.yss 21 | * @author qilong.zql 22 | * @since 2.2.0 23 | */ 24 | public class DataSourceTracerKeys { 25 | public static final String CONNECTION_ESTABLISH_COST = "connection.establish.span"; 26 | 27 | public static final String DB_EXECUTE_COST = "db.execute.cost"; 28 | 29 | public static final String SQL = "sql"; 30 | 31 | public static final String DATABASE_TYPE = "database.type"; 32 | 33 | public static final String DATABASE_NAME = "database.name"; 34 | 35 | public static final String DATABASE_ENDPOINT = "database.endpoint"; 36 | 37 | public static final String LOCAL_APP = "local.app"; 38 | 39 | public static final String START_TIME = "start.time"; 40 | 41 | } -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-datasource-plugin/src/main/java/com/alipay/sofa/tracer/plugins/datasource/tracer/Endpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.datasource.tracer; 18 | 19 | /** 20 | * @author shusong.yss 21 | * @author qilong.zql 22 | * @since 2.2.0 23 | */ 24 | public class Endpoint { 25 | 26 | private String host; 27 | 28 | private int port; 29 | 30 | public String getHost() { 31 | return host; 32 | } 33 | 34 | public void setHost(String host) { 35 | this.host = host; 36 | } 37 | 38 | public int getPort() { 39 | return port; 40 | } 41 | 42 | public void setPort(int port) { 43 | this.port = port; 44 | } 45 | 46 | public String getEndpoint() { 47 | return host + ":" + port; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "Endpoint{" + "host='" + host + '\'' + ", port=" + port + '}'; 53 | } 54 | } -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-datasource-plugin/src/main/java/com/alipay/sofa/tracer/plugins/datasource/tracer/KeyValueAnnotation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.datasource.tracer; 18 | 19 | /** 20 | * @author shusong.yss 21 | * @author qilong.zql 22 | * @since 2.2.0 23 | */ 24 | public class KeyValueAnnotation { 25 | private final String key; 26 | 27 | private final String value; 28 | 29 | public KeyValueAnnotation(String key, String value) { 30 | this.key = key; 31 | this.value = value; 32 | } 33 | 34 | public String getKey() { 35 | return key; 36 | } 37 | 38 | public String getValue() { 39 | return value; 40 | } 41 | } -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-datasource-plugin/src/test/java/com/sofa/tracer/plugins/datasource/TestUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.sofa.tracer.plugins.datasource; 18 | 19 | /** 20 | * @author qilong.zql 21 | * @since 2.2.2 22 | */ 23 | public class TestUtil { 24 | public static void waitForAsyncLog() throws InterruptedException { 25 | // wait flush log to file... (500ms is just expected time) 26 | Thread.sleep(500); 27 | } 28 | } -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-datasource-plugin/src/test/java/com/sofa/tracer/plugins/datasource/base/FakeInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.sofa.tracer.plugins.datasource.base; 18 | 19 | import com.alipay.sofa.tracer.plugins.datasource.Interceptor; 20 | 21 | /** 22 | * @author shusong.yss 23 | * @author qilong.zql 24 | * @since 2.2.0 25 | */ 26 | public class FakeInterceptor implements Interceptor { 27 | 28 | @Override 29 | public Object intercept(Chain chain) throws Exception { 30 | Object reVal = null; 31 | try { 32 | System.out.println("before interceptor"); 33 | reVal = chain.proceed(); 34 | System.out.println("after interceptor"); 35 | } finally { 36 | System.out.println("finally interceptor"); 37 | } 38 | return reVal; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-datasource-plugin/src/test/java/com/sofa/tracer/plugins/datasource/bean/AbstractService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.sofa.tracer.plugins.datasource.bean; 18 | 19 | /** 20 | * @author qilong.zql 21 | * @since 2.3.2 22 | */ 23 | public class AbstractService implements InterfaceA { 24 | @Override 25 | public String serviceA() { 26 | return "serviceA"; 27 | } 28 | 29 | @Override 30 | public String serviceB() { 31 | return "serviceB"; 32 | } 33 | } -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-datasource-plugin/src/test/java/com/sofa/tracer/plugins/datasource/bean/ConcreteClassService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.sofa.tracer.plugins.datasource.bean; 18 | 19 | /** 20 | * @author qilong.zql 21 | * @since 2.3.2 22 | */ 23 | public class ConcreteClassService extends AbstractService { 24 | public String service() { 25 | return "concreteClassService"; 26 | } 27 | } -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-datasource-plugin/src/test/java/com/sofa/tracer/plugins/datasource/bean/InterfaceA.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.sofa.tracer.plugins.datasource.bean; 18 | 19 | /** 20 | * @author qilong.zql 21 | * @sicne 2.3.2 22 | */ 23 | public interface InterfaceA extends InterfaceB { 24 | String serviceA(); 25 | } -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-datasource-plugin/src/test/java/com/sofa/tracer/plugins/datasource/bean/InterfaceB.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.sofa.tracer.plugins.datasource.bean; 18 | 19 | /** 20 | * @author qilong.zql 21 | * @since 2.3.2 22 | */ 23 | public interface InterfaceB { 24 | String serviceB(); 25 | } -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-datasource-plugin/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | mock-maker-inline -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-dubbo-2.6.x-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tracer-all-parent 7 | com.alipay.sofa 8 | 3.1.10 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | sofa-tracer-dubbo-2.6.x-plugin 13 | 14 | 15 | 16 | com.alibaba 17 | dubbo 18 | 2.6.2 19 | provided 20 | 21 | 22 | com.alipay.sofa 23 | tracer-core 24 | 25 | 26 | junit 27 | junit 28 | test 29 | 30 | 31 | commons-io 32 | commons-io 33 | test 34 | 35 | 36 | com.alibaba 37 | fastjson 38 | 39 | 40 | org.javassist 41 | javassist 42 | test 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-dubbo-2.6.x-plugin/src/main/java/com/alipay/sofa/tracer/plugins/dubbo/constants/AttachmentKeyConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.dubbo.constants; 18 | 19 | /** 20 | * @author: guolei.sgl (guolei.sgl@antfin.com) 2019/7/26 5:25 PM 21 | * @since: 22 | **/ 23 | public class AttachmentKeyConstants { 24 | 25 | public static final String SERVER_DESERIALIZE_SIZE = "server.deserialize.size"; 26 | public static final String SERVER_SERIALIZE_SIZE = "server.serialize.size"; 27 | public static final String CLIENT_DESERIALIZE_SIZE = "client.deserialize.size"; 28 | public static final String CLIENT_SERIALIZE_SIZE = "client.serialize.size"; 29 | 30 | public static final String SERVER_DESERIALIZE_TIME = "server.deserialize.time"; 31 | public static final String SERVER_SERIALIZE_TIME = "server.serialize.time"; 32 | public static final String CLIENT_DESERIALIZE_TIME = "client.deserialize.time"; 33 | public static final String CLIENT_SERIALIZE_TIME = "client.serialize.time"; 34 | } 35 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-dubbo-2.6.x-plugin/src/main/resources/META-INF/dubbo/com.alibaba.dubbo.remoting.Codec2: -------------------------------------------------------------------------------- 1 | tracerCodec=com.alipay.sofa.tracer.plugins.dubbo.wrapper.DataSizeCodecWrapper -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-dubbo-2.6.x-plugin/src/main/resources/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter: -------------------------------------------------------------------------------- 1 | dubboSofaTracerFilter=com.alipay.sofa.tracer.plugins.dubbo.DubboSofaTracerFilter 2 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-dubbo-2.6.x-plugin/src/test/java/com/alipay/sofa/tracer/plugins/dubbo/impl/DubboServiceImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.dubbo.impl; 18 | 19 | import com.alipay.sofa.tracer.plugins.dubbo.service.DubboService; 20 | 21 | /** 22 | * @author: guolei.sgl (guolei.sgl@antfin.com) 2019/2/27 8:39 PM 23 | * @since: 24 | **/ 25 | public class DubboServiceImpl implements DubboService { 26 | @Override 27 | public String echoStr(String name) { 28 | return name; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-dubbo-2.6.x-plugin/src/test/java/com/alipay/sofa/tracer/plugins/dubbo/service/DubboService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.dubbo.service; 18 | 19 | /** 20 | * @author: guolei.sgl (guolei.sgl@antfin.com) 2019/2/27 8:38 PM 21 | * @since: 22 | **/ 23 | public interface DubboService { 24 | 25 | String echoStr(String name); 26 | } 27 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-dubbo-common-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tracer-all-parent 7 | com.alipay.sofa 8 | 3.1.10 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | sofa-tracer-dubbo-common-plugin 14 | 15 | 16 | 17 | com.alibaba 18 | dubbo 19 | 2.6.12 20 | provided 21 | 22 | 23 | 24 | org.apache.dubbo 25 | dubbo 26 | 2.7.3 27 | provided 28 | 29 | 30 | 31 | com.alipay.sofa 32 | tracer-core 33 | 34 | 35 | junit 36 | junit 37 | test 38 | 39 | 40 | commons-io 41 | commons-io 42 | test 43 | 44 | 45 | com.alibaba 46 | fastjson 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-dubbo-common-plugin/src/main/java/com/alipay/sofa/tracer/plugins/dubbo/constants/AttachmentKeyConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.dubbo.constants; 18 | 19 | /** 20 | * @author: guolei.sgl (guolei.sgl@antfin.com) 2019/7/26 5:25 PM 21 | * @since: 22 | **/ 23 | public class AttachmentKeyConstants { 24 | 25 | public static final String SERVER_DESERIALIZE_SIZE = "server.deserialize.size"; 26 | public static final String SERVER_SERIALIZE_SIZE = "server.serialize.size"; 27 | public static final String CLIENT_DESERIALIZE_SIZE = "client.deserialize.size"; 28 | public static final String CLIENT_SERIALIZE_SIZE = "client.serialize.size"; 29 | 30 | public static final String SERVER_DESERIALIZE_TIME = "server.deserialize.time"; 31 | public static final String SERVER_SERIALIZE_TIME = "server.serialize.time"; 32 | public static final String CLIENT_DESERIALIZE_TIME = "client.deserialize.time"; 33 | public static final String CLIENT_SERIALIZE_TIME = "client.serialize.time"; 34 | } 35 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-dubbo-common-plugin/src/main/resources/META-INF/dubbo/com.alibaba.dubbo.remoting.Codec2: -------------------------------------------------------------------------------- 1 | tracerCodec=com.alipay.sofa.tracer.plugins.dubbo26x.wrapper.DataSizeCodecWrapper -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-dubbo-common-plugin/src/main/resources/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter: -------------------------------------------------------------------------------- 1 | dubboSofaTracerFilter=com.alipay.sofa.tracer.plugins.dubbo26x.DubboSofaTracerFilter 2 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-dubbo-common-plugin/src/main/resources/META-INF/dubbo/org.apache.dubbo.remoting.Codec2: -------------------------------------------------------------------------------- 1 | tracerCodec=com.alipay.sofa.tracer.plugins.dubbo27x.wrapper.DataSizeCodecWrapper -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-dubbo-common-plugin/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.Filter: -------------------------------------------------------------------------------- 1 | dubboSofaTracerFilter=com.alipay.sofa.tracer.plugins.dubbo27x.DubboSofaTracerFilter -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-dubbo-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tracer-all-parent 7 | com.alipay.sofa 8 | 3.1.10 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | sofa-tracer-dubbo-plugin 13 | 14 | 15 | 16 | org.apache.dubbo 17 | dubbo 18 | 2.7.3 19 | provided 20 | 21 | 22 | com.alipay.sofa 23 | tracer-core 24 | 25 | 26 | junit 27 | junit 28 | test 29 | 30 | 31 | commons-io 32 | commons-io 33 | test 34 | 35 | 36 | com.alibaba 37 | fastjson 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-dubbo-plugin/src/main/resources/META-INF/dubbo/com.alibaba.dubbo.remoting.Codec2: -------------------------------------------------------------------------------- 1 | tracerCodec=com.alipay.sofa.tracer.plugins.dubbo.wrapper.DataSizeCodecWrapper -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-dubbo-plugin/src/main/resources/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter: -------------------------------------------------------------------------------- 1 | dubboSofaTracerFilter=com.alipay.sofa.tracer.plugins.dubbo.DubboSofaTracerFilter 2 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-dubbo-plugin/src/test/java/com/alipay/sofa/tracer/plugins/dubbo/impl/DubboServiceImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.dubbo.impl; 18 | 19 | import com.alipay.sofa.tracer.plugins.dubbo.service.DubboService; 20 | 21 | /** 22 | * @author: guolei.sgl (guolei.sgl@antfin.com) 2019/2/27 8:39 PM 23 | * @since: 24 | **/ 25 | public class DubboServiceImpl implements DubboService { 26 | @Override 27 | public String echoStr(String name) { 28 | return name; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-dubbo-plugin/src/test/java/com/alipay/sofa/tracer/plugins/dubbo/service/DubboService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.dubbo.service; 18 | 19 | /** 20 | * @author: guolei.sgl (guolei.sgl@antfin.com) 2019/2/27 8:38 PM 21 | * @since: 22 | **/ 23 | public interface DubboService { 24 | 25 | String echoStr(String name); 26 | } 27 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-flexible-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tracer-all-parent 7 | com.alipay.sofa 8 | 3.1.10 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | sofa-tracer-flexible-plugin 14 | 15 | 16 | 17 | 18 | com.alipay.sofa 19 | tracer-core 20 | 21 | 22 | org.slf4j 23 | slf4j-api 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-flexible-plugin/src/main/java/com/alipay/sofa/tracer/plugin/flexible/annotations/Tracer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugin.flexible.annotations; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * @author: guolei.sgl (guolei.sgl@antfin.com) 2019/8/2 11:39 AM 26 | * @since: 27 | **/ 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Target({ ElementType.METHOD }) 30 | public @interface Tracer { 31 | /** 32 | * operateName 33 | * @return 34 | */ 35 | String operateName() default ""; 36 | } 37 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-httpclient-plugin/src/main/java/com/alipay/sofa/tracer/plugins/httpclient/HttpClientRequestCarrier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.httpclient; 18 | 19 | import io.opentracing.propagation.TextMap; 20 | import org.apache.http.HttpRequest; 21 | import org.apache.http.message.BasicHeader; 22 | 23 | import java.util.Iterator; 24 | import java.util.Map; 25 | 26 | /** 27 | * HttpClientRequestCarrier 28 | * 29 | * @author yangguanchao 30 | * @since 2018/08/11 31 | */ 32 | public class HttpClientRequestCarrier implements TextMap { 33 | 34 | private final HttpRequest request; 35 | 36 | public HttpClientRequestCarrier(HttpRequest request) { 37 | this.request = request; 38 | } 39 | 40 | @Override 41 | public Iterator> iterator() { 42 | // no operation 43 | throw new UnsupportedOperationException(); 44 | } 45 | 46 | @Override 47 | public void put(String key, String value) { 48 | request.addHeader(new BasicHeader(key, value)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-httpclient-plugin/src/test/java/com/alipay/sofa/tracer/plugins/httpclient/TestUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.httpclient; 18 | 19 | /** 20 | * @author qilong.zql 21 | */ 22 | public class TestUtil { 23 | public static void waitForAsyncLog() throws InterruptedException { 24 | // wait flush log to file... (500ms is just expected time) 25 | Thread.sleep(500); 26 | } 27 | } -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-httpclient-plugin/src/test/java/com/alipay/sofa/tracer/plugins/httpclient/base/SpringBootWebApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.httpclient.base; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | 21 | /** 22 | * SpringBootWebApplication 23 | * 24 | * @author yangguanchao 25 | * @since 2018/08/07 26 | */ 27 | @org.springframework.boot.autoconfigure.SpringBootApplication 28 | public class SpringBootWebApplication { 29 | 30 | public static void main(String[] args) throws Exception { 31 | SpringApplication springApplication = new SpringApplication(SpringBootWebApplication.class); 32 | springApplication.run(args); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-httpclient-plugin/src/test/resources/application-non-json.properties: -------------------------------------------------------------------------------- 1 | com.alipay.sofa.tracer.jsonOutput=false -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-httpclient-plugin/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=test 2 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-httpclient-plugin/src/test/resources/sofa.tracer.properties: -------------------------------------------------------------------------------- 1 | global_json_format_output=false 2 | spring.application.name=test -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-kafkamq-plugin/src/test/java/com/sofa/tracer/plugins/kafka/base/MockSofaTracerSpringKafkaTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.sofa.tracer.plugins.kafka.base; 18 | 19 | import org.junit.Test; 20 | import org.springframework.beans.factory.annotation.Autowired; 21 | import org.springframework.kafka.core.KafkaTemplate; 22 | 23 | import java.util.Objects; 24 | 25 | /** 26 | * MockSofaTracerSpringKafkaTest 27 | * 28 | * @author chenchen6 2020/9/13 22:22 29 | * @since 3.1.0 30 | */ 31 | public class MockSofaTracerSpringKafkaTest { 32 | 33 | @Autowired 34 | private KafkaTemplate kafkaTemplate; 35 | 36 | @Test 37 | public void test() { 38 | if (Objects.isNull(kafkaTemplate)) { 39 | return; 40 | } 41 | kafkaTemplate.send("spring", "message"); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-mongodb-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tracer-all-parent 7 | com.alipay.sofa 8 | 3.1.10 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | sofa-tracer-mongodb-plugin 14 | 15 | 16 | 17 | 18 | com.alipay.sofa 19 | tracer-core 20 | 21 | 22 | 23 | com.alipay.sofa 24 | tracer-extensions 25 | 26 | 27 | 28 | org.mongodb 29 | mongodb-driver 30 | 3.8.2 31 | provided 32 | 33 | 34 | 35 | org.springframework.data 36 | spring-data-mongodb 37 | provided 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-okhttp-plugin/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sofastack/sofa-tracer/9686b2f8e4fb3c9dbe4c89c09a0380843b5602a9/sofa-tracer-plugins/sofa-tracer-okhttp-plugin/src/main/resources/application.properties -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-okhttp-plugin/src/main/resources/sofa.tracer.properties: -------------------------------------------------------------------------------- 1 | global_json_format_output=false 2 | spring.application.name=test -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-okhttp-plugin/src/test/java/com/alipay/sofa/tracer/plugins/okhttp/base/SpringBootWebApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.okhttp.base; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | 21 | /** 22 | * 23 | * @author xianglong.chen 24 | * @since 2019/1/17 13:29 25 | */ 26 | @org.springframework.boot.autoconfigure.SpringBootApplication 27 | public class SpringBootWebApplication { 28 | 29 | public static void main(String[] args) throws Exception { 30 | SpringApplication springApplication = new SpringApplication(SpringBootWebApplication.class); 31 | springApplication.run(args); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-rabbitmq-plugin/src/test/java/com/sofa/tracer/plugins/rabbitmq/base/MockSofaTracerConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.sofa.tracer.plugins.rabbitmq.base; 18 | 19 | import com.alipay.common.tracer.core.SofaTracer; 20 | import com.alipay.common.tracer.core.mock.MockSofaTracer; 21 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 22 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 23 | import org.springframework.context.annotation.Bean; 24 | import org.springframework.context.annotation.Configuration; 25 | 26 | /** 27 | * MockSofaTracerConfiguration. 28 | * 29 | * @author chenchen6 2020/8/11 23:49 30 | */ 31 | @Configuration 32 | @EnableAutoConfiguration 33 | public class MockSofaTracerConfiguration { 34 | 35 | @ConditionalOnMissingBean 36 | @Bean 37 | public SofaTracer mockSofaTracer() { 38 | return MockSofaTracer.getMockSofaTracer(); 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-rabbitmq-plugin/src/test/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sofastack/sofa-tracer/9686b2f8e4fb3c9dbe4c89c09a0380843b5602a9/sofa-tracer-plugins/sofa-tracer-rabbitmq-plugin/src/test/resources/application.properties -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-redis-plugin/src/main/java/com/sofa/alipay/tracer/plugins/spring/redis/common/Action.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.sofa.alipay.tracer.plugins.spring.redis.common; 18 | 19 | /** 20 | * @author: guolei.sgl (guolei.sgl@antfin.com) 2019/11/19 7:17 PM 21 | * @since: 22 | **/ 23 | @FunctionalInterface 24 | public interface Action { 25 | 26 | void execute(); 27 | } 28 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-redis-plugin/src/main/java/com/sofa/alipay/tracer/plugins/spring/redis/common/ThrowingAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.sofa.alipay.tracer.plugins.spring.redis.common; 18 | 19 | @FunctionalInterface 20 | public interface ThrowingAction { 21 | 22 | void execute() throws T; 23 | } 24 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-redis-plugin/src/main/java/com/sofa/alipay/tracer/plugins/spring/redis/common/ThrowingSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.sofa.alipay.tracer.plugins.spring.redis.common; 18 | 19 | @FunctionalInterface 20 | public interface ThrowingSupplier { 21 | 22 | V get() throws T; 23 | } 24 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-resttmplate-plugin/src/main/java/com/sofa/alipay/tracer/plugins/rest/RestTemplateRequestCarrier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.sofa.alipay.tracer.plugins.rest; 18 | 19 | import io.opentracing.propagation.TextMap; 20 | import org.springframework.http.HttpRequest; 21 | 22 | import java.util.Iterator; 23 | import java.util.Map; 24 | 25 | /** 26 | * RestTemplateRequestCarrier 27 | * @author: guolei.sgl 28 | * @since: v2.3.0 29 | */ 30 | public class RestTemplateRequestCarrier implements TextMap { 31 | 32 | private final HttpRequest request; 33 | 34 | public RestTemplateRequestCarrier(HttpRequest request) { 35 | this.request = request; 36 | } 37 | 38 | @Override 39 | public Iterator> iterator() { 40 | throw new UnsupportedOperationException(); 41 | } 42 | 43 | @Override 44 | public void put(String key, String value) { 45 | request.getHeaders().add(key, value); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-resttmplate-plugin/src/test/java/com/sofa/tracer/plugins/resttemplate/base/SpringBootWebApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.sofa.tracer.plugins.resttemplate.base; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | 21 | /** 22 | * SpringBootWebApplication 23 | * 24 | * @author yangguanchao 25 | * @since v2.3.0 26 | */ 27 | @org.springframework.boot.autoconfigure.SpringBootApplication 28 | public class SpringBootWebApplication { 29 | 30 | public static void main(String[] args) throws Exception { 31 | SpringApplication springApplication = new SpringApplication(SpringBootWebApplication.class); 32 | springApplication.run(args); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-resttmplate-plugin/src/test/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sofastack/sofa-tracer/9686b2f8e4fb3c9dbe4c89c09a0380843b5602a9/sofa-tracer-plugins/sofa-tracer-resttmplate-plugin/src/test/resources/application.properties -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-rocketmq-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tracer-all-parent 7 | com.alipay.sofa 8 | 3.1.10 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | sofa-tracer-rocketmq-plugin 14 | 15 | 16 | 17 | org.apache.rocketmq 18 | rocketmq-client 19 | provided 20 | 21 | 22 | com.alipay.sofa 23 | tracer-core 24 | 25 | 26 | com.alipay.sofa 27 | tracer-extensions 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-spring-cloud-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tracer-all-parent 7 | com.alipay.sofa 8 | 3.1.10 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | sofa-tracer-spring-cloud-plugin 14 | 15 | 16 | 17 | org.springframework.cloud 18 | spring-cloud-starter-openfeign 19 | true 20 | 21 | 22 | com.alipay.sofa 23 | tracer-core 24 | 25 | 26 | com.alipay.sofa 27 | tracer-extensions 28 | 29 | 30 | 31 | org.springframework 32 | spring-jms 33 | true 34 | 35 | 36 | 37 | org.springframework.integration 38 | spring-integration-core 39 | true 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-springmessage-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tracer-all-parent 7 | com.alipay.sofa 8 | 3.1.10 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | sofa-tracer-springmessage-plugin 14 | 15 | 16 | 17 | com.alipay.sofa 18 | tracer-core 19 | 20 | 21 | com.alipay.sofa 22 | tracer-extensions 23 | 24 | 25 | 26 | org.springframework.integration 27 | spring-integration-core 28 | true 29 | 30 | 31 | 32 | org.apache.rocketmq 33 | rocketmq-client 34 | true 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-springmvc-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | tracer-all-parent 6 | com.alipay.sofa 7 | 3.1.10 8 | ../../pom.xml 9 | 10 | 11 | sofa-tracer-springmvc-plugin 12 | 13 | 14 | 15 | com.alipay.sofa 16 | tracer-core 17 | 18 | 19 | com.alipay.sofa 20 | tracer-extensions 21 | 22 | 23 | 24 | javax.servlet 25 | javax.servlet-api 26 | true 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-webflux 31 | true 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-springmvc-plugin/src/main/java/com/alipay/sofa/tracer/plugins/springmvc/SpringMvcHeadersCarrier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.springmvc; 18 | 19 | import io.opentracing.propagation.TextMap; 20 | 21 | import java.util.HashMap; 22 | import java.util.Iterator; 23 | import java.util.Map; 24 | 25 | /** 26 | * @author yangguanchao 27 | */ 28 | public class SpringMvcHeadersCarrier implements TextMap { 29 | private HashMap headers; 30 | 31 | public SpringMvcHeadersCarrier(HashMap headers) { 32 | this.headers = headers; 33 | } 34 | 35 | @Override 36 | public void put(String key, String value) { 37 | headers.put(key, value); 38 | } 39 | 40 | @Override 41 | public Iterator> iterator() { 42 | return headers.entrySet().iterator(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-springmvc-plugin/src/main/java/com/alipay/sofa/tracer/plugins/webflux/SofaTraceableRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.webflux; 18 | 19 | import org.springframework.http.HttpHeaders; 20 | 21 | import java.net.URI; 22 | 23 | /** 24 | * @author qilong.zql 25 | * @since 3.0.0 26 | */ 27 | public interface SofaTraceableRequest { 28 | /** 29 | * Returns the method (GET, POST, etc) of the request. 30 | * @return 31 | */ 32 | String getMethod(); 33 | 34 | /** 35 | * Returns the URI of the request. 36 | * @return the URI 37 | */ 38 | URI getUri(); 39 | 40 | /** 41 | * Returns the headers of the request. 42 | * @return the headers 43 | */ 44 | HttpHeaders getHeaders(); 45 | 46 | /** 47 | * Returns the remote address from which the request was sent, if available. 48 | * @return the remote address or {@code null} 49 | */ 50 | String getRemoteAddress(); 51 | } -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-springmvc-plugin/src/main/java/com/alipay/sofa/tracer/plugins/webflux/SofaTraceableResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.webflux; 18 | 19 | import org.springframework.http.HttpHeaders; 20 | 21 | /** 22 | * @author qilong.zql 23 | * @since 3.0.0 24 | */ 25 | public interface SofaTraceableResponse { 26 | /** 27 | * The status of the response. 28 | * @return the status 29 | */ 30 | int getStatus(); 31 | 32 | /** 33 | * Returns the headers of the response. 34 | * @return 35 | */ 36 | HttpHeaders getHeaders(); 37 | } -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-zipkin-plugin/src/main/java/com/alipay/sofa/tracer/plugins/zipkin/properties/ZipkinProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.zipkin.properties; 18 | 19 | /** 20 | * ZipkinProperties 21 | * @author guolei.sgl 22 | * @since v2.3.0 23 | */ 24 | public class ZipkinProperties { 25 | 26 | public static final String ZIPKIN_IS_ENABLED_KEY = "com.alipay.sofa.tracer.zipkin.enabled"; 27 | public static final String ZIPKIN_BASE_URL_KEY = "com.alipay.sofa.tracer.zipkin.baseUrl"; 28 | public static final String ZIPKIN_IS_GZIPPED_KEY = "com.alipay.sofa.tracer.zipkin.gzipped"; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-zipkin-plugin/src/test/java/com/alipay/sofa/tracer/plugins/zipkin/ZipkinSofaTracerSpanRemoteReporterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.plugins.zipkin; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | /** 23 | * ZipkinSofaTracerSpanRemoteReporterTest 24 | * 25 | * @author: guolei.sgl 26 | * @since: v2.3.0 27 | **/ 28 | public class ZipkinSofaTracerSpanRemoteReporterTest { 29 | 30 | @Test 31 | public void testTraceIdToId() { 32 | // hex to decimal 33 | long ff = ZipkinSofaTracerSpanRemoteReporter.traceIdToId("FF"); 34 | Assert.assertTrue(ff == 255); 35 | 36 | long decimal88 = ZipkinSofaTracerSpanRemoteReporter.traceIdToId("8"); 37 | Assert.assertTrue(decimal88 == 8); 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-zipkin-plugin/src/test/resources/sofa.tracer.properties: -------------------------------------------------------------------------------- 1 | com.alipay.sofa.tracer.zipkin.enabled=true 2 | com.alipay.sofa.tracer.zipkin.baseUrl=http://localhost:9411 3 | com.alipay.sofa.tracer.zipkin.gzipped=true -------------------------------------------------------------------------------- /sofa-tracer-plugins/sofa-tracer-zipkin-plugin/src/test/resources/spring-bean.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /tracer-all/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tracer-all-parent 7 | com.alipay.sofa 8 | 3.1.10 9 | 10 | 4.0.0 11 | 12 | tracer-all 13 | 3.1.10 14 | jar 15 | 16 | SOFATracer in one without SOFABoot starter 17 | 18 | 19 | 20 | com.alipay.sofa 21 | tracer-core 22 | 23 | 24 | com.alipay.sofa 25 | tracer-extensions 26 | 27 | 28 | com.alipay.sofa 29 | sofa-tracer-springmvc-plugin 30 | 31 | 32 | com.alipay.sofa 33 | sofa-tracer-httpclient-plugin 34 | 35 | 36 | com.alipay.sofa 37 | sofa-tracer-resttmplate-plugin 38 | 39 | 40 | com.alipay.sofa 41 | sofa-tracer-datasource-plugin 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/appender/TraceAppender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.appender; 18 | 19 | import java.io.IOException; 20 | 21 | /** 22 | * @author yangyanzhao 23 | */ 24 | public interface TraceAppender { 25 | 26 | /** 27 | * flush data 28 | * 29 | * @throws IOException 30 | */ 31 | void flush() throws IOException; 32 | 33 | /** 34 | * Add the log file to be output 35 | * 36 | * @param log 37 | * @throws IOException 38 | */ 39 | void append(String log) throws IOException; 40 | 41 | /** 42 | * clean log 43 | */ 44 | void cleanup(); 45 | } 46 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/appender/config/LogReserveConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.appender.config; 18 | 19 | /** 20 | * @author khotyn 21 | * @since 9/19/16. 22 | */ 23 | public class LogReserveConfig { 24 | private int day; 25 | private int hour; 26 | 27 | public LogReserveConfig(int day, int hour) { 28 | this.hour = hour; 29 | this.day = day; 30 | } 31 | 32 | public int getHour() { 33 | return hour; 34 | } 35 | 36 | public int getDay() { 37 | return day; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/appender/encoder/SpanEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.appender.encoder; 18 | 19 | import io.opentracing.Span; 20 | 21 | import java.io.IOException; 22 | 23 | /** 24 | * SpanEncoder 25 | *

26 | * Tracer Span log encoder, optimized for asynchronous queue calls, does not allow multi-threaded concurrent calls 27 | *

28 | * @author yangguanchao 29 | * @since 2017/06/25 30 | */ 31 | public interface SpanEncoder { 32 | 33 | /** 34 | * Separate fields according to custom rules and prepare to output to file 35 | * 36 | * @param span current span 37 | * @throws IOException 38 | * @return formatted output string 39 | */ 40 | String encode(T span) throws IOException; 41 | } 42 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/appender/manager/ObjectEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.appender.manager; 18 | 19 | /** 20 | * 21 | * @author songzijie 22 | * @version $Id: ObjectEvent.java, v 0.1 2024-10-08 16:10 songzijie Exp $$ 23 | */ 24 | public interface ObjectEvent { 25 | 26 | void clear(); 27 | } -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/appender/manager/SofaTracerSpanEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.appender.manager; 18 | 19 | import com.alipay.common.tracer.core.span.SofaTracerSpan; 20 | 21 | /** 22 | * @author liangen 3/10/17 23 | */ 24 | public class SofaTracerSpanEvent implements ObjectEvent { 25 | private volatile SofaTracerSpan sofaTracerSpan; 26 | 27 | /** 28 | * Getter method for property sofaTracerSpan. 29 | * 30 | * @return property value of sofaTracerSpan 31 | */ 32 | public SofaTracerSpan getSofaTracerSpan() { 33 | return sofaTracerSpan; 34 | } 35 | 36 | /** 37 | * Setter method for property sofaTracerSpan. 38 | * 39 | * @param sofaTracerSpan value to be assigned to property sofaTracerSpan 40 | */ 41 | public void setSofaTracerSpan(SofaTracerSpan sofaTracerSpan) { 42 | this.sofaTracerSpan = sofaTracerSpan; 43 | } 44 | 45 | @Override 46 | public void clear() { 47 | setSofaTracerSpan(null); 48 | } 49 | } -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/appender/manager/SofaTracerSpanEventFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.appender.manager; 18 | 19 | import com.alipay.disruptor.EventFactory; 20 | 21 | /** 22 | * 23 | * @author liangen 24 | * @version $Id: SofaTracerSpanEventFactory.java, v 0.1 October 23, 2017 10:07 AM liangen Exp $ 25 | */ 26 | public class SofaTracerSpanEventFactory implements EventFactory { 27 | 28 | @Override 29 | public SofaTracerSpanEvent newInstance() { 30 | return new SofaTracerSpanEvent(); 31 | } 32 | } -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/appender/manager/StringEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.appender.manager; 18 | 19 | /** 20 | * 21 | * @author luoguimu123 22 | * @version $Id: StringEvent.java, v 0.1 November 21, 2017 7:01 PM luoguimu123 Exp $ 23 | */ 24 | public class StringEvent implements ObjectEvent { 25 | 26 | private volatile String string; 27 | 28 | public String getString() { 29 | return string; 30 | } 31 | 32 | public void setString(String string) { 33 | this.string = string; 34 | } 35 | 36 | @Override 37 | public void clear() { 38 | setString(null); 39 | } 40 | } -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/appender/manager/StringEventFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.appender.manager; 18 | 19 | import com.alipay.disruptor.EventFactory; 20 | 21 | /** 22 | * 23 | * @author luoguimu123 24 | * @version $Id: StringEventFactory.java, v 0.1 November 21, 2017 7:00 PM luoguimu123 Exp $ 25 | */ 26 | public class StringEventFactory implements EventFactory { 27 | @Override 28 | public StringEvent newInstance() { 29 | return new StringEvent(); 30 | } 31 | } -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/appender/self/Timestamp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.appender.self; 18 | 19 | import java.text.SimpleDateFormat; 20 | 21 | /*** 22 | * @author yangguanchao 23 | * @since 2017/06/17 24 | */ 25 | public class Timestamp { 26 | 27 | public static String currentTime() { 28 | return getSimpleDateFormat().format(System.currentTimeMillis()); 29 | } 30 | 31 | public static String format(long time) { 32 | return getSimpleDateFormat().format(time); 33 | } 34 | 35 | private static SimpleDateFormat getSimpleDateFormat() { 36 | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/configuration/SofaTracerExternalConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.configuration; 18 | 19 | /** 20 | * The interface of the external configuration class, which is implemented by external code 21 | * @author luoguimu123 22 | * @version $Id: SofaTracerExternalConfiguration.java, v 0.1 October 11, 2017 12:03 PM luoguimu123 Exp $ 23 | */ 24 | public interface SofaTracerExternalConfiguration { 25 | 26 | /** 27 | * get value by input key 28 | * @param key 29 | * @return 30 | */ 31 | String getValue(String key); 32 | 33 | /** 34 | * Whether the specified key exists 35 | * @param key 36 | * @return 37 | */ 38 | boolean contains(String key); 39 | 40 | } -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/exception/EmptyTracerStateStringException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.exception; 18 | 19 | /** 20 | * 21 | * @author luoguimu123 22 | * @version $Id: EmptyTracerStateStringException.java, v 0.1 June 22, 2017 10:55 AM luoguimu123 Exp $ 23 | */ 24 | public class EmptyTracerStateStringException extends RuntimeException { 25 | 26 | public EmptyTracerStateStringException() { 27 | super("Cannot convert empty string to tracer state"); 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/exception/SamplingStrategyErrorException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.exception; 18 | 19 | /** 20 | * Exception when sampling part of the code error 21 | * @author luoguimu123 22 | * @version $Id: SamplingStrategyErrorException.java, v 0.1 June 22, 2017 10:56 AM luoguimu123 Exp $ 23 | */ 24 | public class SamplingStrategyErrorException extends RuntimeException { 25 | 26 | public SamplingStrategyErrorException(String msg) { 27 | super(msg); 28 | } 29 | 30 | public SamplingStrategyErrorException(String msg, Throwable cause) { 31 | super(msg, cause); 32 | } 33 | } -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/exception/SofaTracerRuntimeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.exception; 18 | 19 | /** 20 | * SofaTracerRuntimeException 21 | * 22 | * @author yangguanchao 23 | * @since 2017/06/17 24 | */ 25 | public class SofaTracerRuntimeException extends RuntimeException { 26 | 27 | public SofaTracerRuntimeException(String msg) { 28 | super(msg); 29 | } 30 | 31 | public SofaTracerRuntimeException(String desc, Throwable t) { 32 | super(desc, t); 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return super.getMessage(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/exception/UnsupportedFormatException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.exception; 18 | 19 | import io.opentracing.propagation.Format; 20 | 21 | /** 22 | * format does not support exception thrown 23 | * 24 | * @author luoguimu123 25 | * @version $Id: UnsupportedFormatException.java, v 0.1 June 22, 2017 10:57 AM luoguimu123 Exp $ 26 | */ 27 | public class UnsupportedFormatException extends RuntimeException { 28 | public UnsupportedFormatException(Format format) { 29 | super(format.toString()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/extensions/SpanExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.extensions; 18 | 19 | import io.opentracing.Span; 20 | 21 | /** 22 | * 23 | * @author luoguimu123 24 | * @version $Id: TracerExtension.java, v 0.1 June 23, 2017 11:48 AM luoguimu123 Exp $ 25 | */ 26 | public interface SpanExtension { 27 | /** 28 | * Called at the beginning of span 29 | * @param currentSpan 30 | */ 31 | void logStartedSpan(Span currentSpan); 32 | 33 | /** 34 | * Called at the end of span 35 | * @param currentSpan 36 | */ 37 | void logStoppedSpan(Span currentSpan); 38 | 39 | /** 40 | * Called at the end of span in Runnable 41 | * @param currentSpan 42 | */ 43 | void logStoppedSpanInRunnable(Span currentSpan); 44 | 45 | /** 46 | * return support name 47 | * @return 48 | */ 49 | String supportName(); 50 | 51 | } -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/holder/SofaTraceContextHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.holder; 18 | 19 | import com.alipay.common.tracer.core.context.trace.SofaTraceContext; 20 | import com.alipay.common.tracer.core.context.trace.SofaTracerThreadLocalTraceContext; 21 | 22 | /** 23 | * SofaTraceContextHolder 24 | * 25 | * @author yangguanchao 26 | * @since 2017/06/17 27 | */ 28 | public class SofaTraceContextHolder { 29 | 30 | /** 31 | * singleton SofaTraceContext 32 | */ 33 | private static final SofaTraceContext SOFA_TRACE_CONTEXT = new SofaTracerThreadLocalTraceContext(); 34 | 35 | /** 36 | * Get threadlocal alipay trace context 37 | * @return SofaTraceContext 38 | */ 39 | public static SofaTraceContext getSofaTraceContext() { 40 | return SOFA_TRACE_CONTEXT; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/listener/SpanReportListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.listener; 18 | 19 | import com.alipay.common.tracer.core.span.SofaTracerSpan; 20 | 21 | /** 22 | * SpanReportListener:Reporter extension interface 23 | * 24 | * @author yangguanchao 25 | * @since 2018/05/07 26 | */ 27 | public interface SpanReportListener { 28 | 29 | /** 30 | * Reporter extension callback method 31 | * It can be printed to the log, or it can be reported to some remote server 32 | * @param sofaTracerSpan 33 | */ 34 | void onSpanReport(SofaTracerSpan sofaTracerSpan); 35 | } 36 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/mock/MockSofaTracer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.mock; 18 | 19 | import com.alipay.common.tracer.core.SofaTracer; 20 | 21 | /** 22 | * MockSofaTracer 23 | * 24 | * @author yangguanchao 25 | * @since 2017/08/10 26 | */ 27 | public class MockSofaTracer { 28 | 29 | private static final String MOCK_TRACER = "MOCK_TRACER"; 30 | 31 | private volatile static SofaTracer MOCK_SOFA_TRACER = null; 32 | 33 | /** 34 | * Get the mocked OpenTracing Implementation 35 | * @return mock tracer 36 | */ 37 | public static SofaTracer getMockSofaTracer() { 38 | if (MOCK_SOFA_TRACER == null) { 39 | synchronized (MockSofaTracer.class) { 40 | if (MOCK_SOFA_TRACER == null) { 41 | MOCK_SOFA_TRACER = new SofaTracer.Builder(MOCK_TRACER).build(); 42 | } 43 | } 44 | } 45 | return MOCK_SOFA_TRACER; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/registry/ExtendFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.registry; 18 | 19 | import io.opentracing.propagation.Format; 20 | import io.opentracing.propagation.TextMap; 21 | 22 | public interface ExtendFormat extends Format { 23 | final class Builtin implements ExtendFormat { 24 | private final String name; 25 | 26 | private Builtin(String name) { 27 | this.name = name; 28 | } 29 | 30 | public final static Format B3_TEXT_MAP = new ExtendFormat.Builtin( 31 | "B3_TEXT_MAP"); 32 | public final static Format B3_HTTP_HEADERS = new ExtendFormat.Builtin( 33 | "B3_HTTP_HEADERS"); 34 | 35 | @Override 36 | public String toString() { 37 | return ExtendFormat.Builtin.class.getSimpleName() + "." + name; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/registry/TextMapB3Formatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.registry; 18 | 19 | import com.alipay.common.tracer.core.utils.StringUtils; 20 | import io.opentracing.propagation.Format; 21 | import io.opentracing.propagation.TextMap; 22 | 23 | /** 24 | * TextMapFormatter 25 | * 26 | * @author yangguanchao 27 | * @since 2017/06/23 28 | */ 29 | public class TextMapB3Formatter extends AbstractTextB3Formatter { 30 | 31 | @Override 32 | public Format getFormatType() { 33 | return ExtendFormat.Builtin.B3_TEXT_MAP; 34 | } 35 | 36 | @Override 37 | protected String encodedValue(String value) { 38 | if (StringUtils.isBlank(value)) { 39 | return StringUtils.EMPTY_STRING; 40 | } 41 | return value; 42 | } 43 | 44 | @Override 45 | protected String decodedValue(String value) { 46 | if (StringUtils.isBlank(value)) { 47 | return StringUtils.EMPTY_STRING; 48 | } 49 | return value; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/registry/TextMapFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.registry; 18 | 19 | import com.alipay.common.tracer.core.utils.StringUtils; 20 | import io.opentracing.propagation.Format; 21 | import io.opentracing.propagation.TextMap; 22 | 23 | /** 24 | * TextMapFormatter 25 | * 26 | * @author yangguanchao 27 | * @since 2017/06/23 28 | */ 29 | public class TextMapFormatter extends AbstractTextFormatter { 30 | 31 | @Override 32 | public Format getFormatType() { 33 | return Format.Builtin.TEXT_MAP; 34 | } 35 | 36 | @Override 37 | protected String encodedValue(String value) { 38 | if (StringUtils.isBlank(value)) { 39 | return StringUtils.EMPTY_STRING; 40 | } 41 | return value; 42 | } 43 | 44 | @Override 45 | protected String decodedValue(String value) { 46 | if (StringUtils.isBlank(value)) { 47 | return StringUtils.EMPTY_STRING; 48 | } 49 | return value; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/reporter/facade/Reporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.reporter.facade; 18 | 19 | import com.alipay.common.tracer.core.span.SofaTracerSpan; 20 | 21 | /** 22 | * Reporter 23 | * 24 | * @author yangguanchao 25 | * @since 2017/07/14 26 | */ 27 | public interface Reporter { 28 | 29 | /** 30 | * Persistence type reported to the remote server 31 | */ 32 | String REMOTE_REPORTER = "REMOTE_REPORTER"; 33 | 34 | /** 35 | * Combined reporting type 36 | */ 37 | String COMPOSITE_REPORTER = "COMPOSITE_REPORTER"; 38 | 39 | /** 40 | * get reporter type 41 | * @return 42 | */ 43 | String getReporterType(); 44 | 45 | /** 46 | * report span 47 | * @param span 48 | */ 49 | void report(SofaTracerSpan span); 50 | 51 | /** 52 | * turn off output ability 53 | */ 54 | void close(); 55 | } 56 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/samplers/Sampler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.samplers; 18 | 19 | import com.alipay.common.tracer.core.span.SofaTracerSpan; 20 | 21 | public interface Sampler { 22 | 23 | /** 24 | * @param sofaTracerSpan The operation name set on the span 25 | * @return whether or not the new trace should be sampled 26 | */ 27 | SamplingStatus sample(SofaTracerSpan sofaTracerSpan); 28 | 29 | /** 30 | * get sampler type 31 | * @return 32 | */ 33 | String getType(); 34 | 35 | /** 36 | * Release any resources used by the sampler. 37 | */ 38 | void close(); 39 | } 40 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/samplers/SamplingStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.samplers; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | 22 | public class SamplingStatus { 23 | 24 | private boolean isSampled = false; 25 | 26 | /** 27 | * Allow tags to be placed at RootSpan 28 | */ 29 | private Map tags = new HashMap(); 30 | 31 | public boolean isSampled() { 32 | return isSampled; 33 | } 34 | 35 | public void setSampled(boolean sampled) { 36 | isSampled = sampled; 37 | } 38 | 39 | public Map getTags() { 40 | return tags; 41 | } 42 | 43 | public void setTags(Map tags) { 44 | this.tags = tags; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/core/utils/DateUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.utils; 18 | 19 | import java.util.Date; 20 | 21 | /** 22 | * @author zhile 23 | * @version : DateUtils.java, v 0.1 2021年09月23日 下午3:55 zhile Exp $ 24 | */ 25 | public class DateUtils { 26 | 27 | /** 28 | * 获取离下一分钟的毫秒数 29 | */ 30 | public static long diffNextMinute(Date date) { 31 | long now = date.getTime(); 32 | long nextMinute = (now / (60 * 1000) + 1) * 60 * 1000; 33 | return nextMinute - now; 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/common/tracer/util/Desensitizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.util; 18 | 19 | /** 20 | *

created at 2021/3/26 21 | * 22 | * @author xiangfeng.xzc 23 | */ 24 | public interface Desensitizer { 25 | /** 26 | * Desensitize str 27 | * @param str 28 | * @return 29 | */ 30 | String desensitize(String str); 31 | } 32 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/AlertException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | /** 19 | * Used to alert {@link EventProcessor}s waiting at a {@link SequenceBarrier} of status changes. 20 | *

21 | * It does not fill in a stack trace for performance reasons. 22 | */ 23 | @SuppressWarnings("serial") 24 | public final class AlertException extends Exception { 25 | /** 26 | * Pre-allocated exception to avoid garbage generation 27 | */ 28 | public static final AlertException INSTANCE = new AlertException(); 29 | 30 | /** 31 | * Private constructor so only a single instance exists. 32 | */ 33 | private AlertException() { 34 | } 35 | 36 | /** 37 | * Overridden so the stack trace is not filled in for this exception for performance reasons. 38 | * 39 | * @return this instance. 40 | */ 41 | @Override 42 | public Throwable fillInStackTrace() { 43 | return this; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/BusySpinWaitStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | /** 19 | * Busy Spin strategy that uses a busy spin loop for {@link com.alipay.disruptor.EventProcessor}s waiting on a barrier. 20 | *

21 | * This strategy will use CPU resource to avoid syscalls which can introduce latency jitter. It is best 22 | * used when threads can be bound to specific CPU cores. 23 | */ 24 | public final class BusySpinWaitStrategy implements WaitStrategy { 25 | @Override 26 | public long waitFor(final long sequence, Sequence cursor, final Sequence dependentSequence, 27 | final SequenceBarrier barrier) throws AlertException, InterruptedException { 28 | long availableSequence; 29 | 30 | while ((availableSequence = dependentSequence.get()) < sequence) { 31 | barrier.checkAlert(); 32 | } 33 | 34 | return availableSequence; 35 | } 36 | 37 | @Override 38 | public void signalAllWhenBlocking() { 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/Cursored.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | /** 19 | * Implementors of this interface must provide a single long value 20 | * that represents their current cursor value. Used during dynamic 21 | * add/remove of Sequences from a 22 | * {@link SequenceGroups#addSequences(Object, java.util.concurrent.atomic.AtomicReferenceFieldUpdater, Cursored, Sequence...)}. 23 | */ 24 | public interface Cursored { 25 | /** 26 | * Get the current cursor value. 27 | * 28 | * @return current cursor value 29 | */ 30 | long getCursor(); 31 | } 32 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/DataProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | public interface DataProvider { 19 | T get(long sequence); 20 | } 21 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/EventFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | /** 19 | * Called by the {@link RingBuffer} to pre-populate all the events to fill the RingBuffer. 20 | * 21 | * @param event implementation storing the data for sharing during exchange or parallel coordination of an event. 22 | */ 23 | public interface EventFactory { 24 | /* 25 | * Implementations should instantiate an event object, with all memory already allocated where possible. 26 | */ 27 | T newInstance(); 28 | } -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/EventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | /** 19 | * Callback interface to be implemented for processing events as they become available in the {@link RingBuffer} 20 | * 21 | * @param event implementation storing the data for sharing during exchange or parallel coordination of an event. 22 | * @see BatchEventProcessor#setExceptionHandler(ExceptionHandler) if you want to handle exceptions propagated out of the handler. 23 | */ 24 | public interface EventHandler { 25 | /** 26 | * Called when a publisher has published an event to the {@link RingBuffer} 27 | * 28 | * @param event published to the {@link RingBuffer} 29 | * @param sequence of the event being processed 30 | * @param endOfBatch flag to indicate if this is the last event in a batch from the {@link RingBuffer} 31 | * @throws Exception if the EventHandler would like the exception handled further up the chain. 32 | */ 33 | void onEvent(T event, long sequence, boolean endOfBatch) throws Exception; 34 | } 35 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/EventProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | /** 19 | * EventProcessors waitFor events to become available for consumption from the {@link RingBuffer} 20 | *

21 | * An EventProcessor will generally be associated with a Thread for execution. 22 | */ 23 | public interface EventProcessor extends Runnable { 24 | /** 25 | * Get a reference to the {@link Sequence} being used by this {@link EventProcessor}. 26 | * 27 | * @return reference to the {@link Sequence} for this {@link EventProcessor} 28 | */ 29 | Sequence getSequence(); 30 | 31 | /** 32 | * Signal that this EventProcessor should stop when it has finished consuming at the next clean break. 33 | * It will call {@link SequenceBarrier#alert()} to notify the thread to check status. 34 | */ 35 | void halt(); 36 | 37 | boolean isRunning(); 38 | } 39 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/EventReleaseAware.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | public interface EventReleaseAware { 19 | void setEventReleaser(EventReleaser eventReleaser); 20 | } 21 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/EventReleaser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | public interface EventReleaser { 19 | void release(); 20 | } 21 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/EventSequencer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | public interface EventSequencer extends DataProvider, Sequenced { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/EventTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | /** 19 | *

Implementations translate (write) data representations into events claimed from the {@link RingBuffer}.

20 | * 21 | *

When publishing to the RingBuffer, provide an EventTranslator. The RingBuffer will select the next available 22 | * event by sequence and provide it to the EventTranslator (which should update the event), before publishing 23 | * the sequence update.

24 | * 25 | * @param event implementation storing the data for sharing during exchange or parallel coordination of an event. 26 | */ 27 | public interface EventTranslator { 28 | /** 29 | * Translate a data representation into fields set in given event 30 | * 31 | * @param event into which the data should be translated. 32 | * @param sequence that is assigned to event. 33 | */ 34 | void translateTo(final T event, long sequence); 35 | } 36 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/EventTranslatorOneArg.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | /** 19 | * Implementations translate another data representations into events claimed from the {@link RingBuffer} 20 | * 21 | * @param event implementation storing the data for sharing during exchange or parallel coordination of an event. 22 | * @see EventTranslator 23 | */ 24 | public interface EventTranslatorOneArg { 25 | /** 26 | * Translate a data representation into fields set in given event 27 | * 28 | * @param event into which the data should be translated. 29 | * @param sequence that is assigned to event. 30 | * @param arg0 The first user specified argument to the translator 31 | */ 32 | void translateTo(final T event, long sequence, final A arg0); 33 | } 34 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/EventTranslatorThreeArg.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | /** 19 | * Implementations translate another data representations into events claimed from the {@link RingBuffer} 20 | * 21 | * @param event implementation storing the data for sharing during exchange or parallel coordination of an event. 22 | * @see EventTranslator 23 | */ 24 | public interface EventTranslatorThreeArg { 25 | /** 26 | * Translate a data representation into fields set in given event 27 | * 28 | * @param event into which the data should be translated. 29 | * @param sequence that is assigned to event. 30 | * @param arg0 The first user specified argument to the translator 31 | * @param arg1 The second user specified argument to the translator 32 | * @param arg2 The third user specified argument to the translator 33 | */ 34 | void translateTo(final T event, long sequence, final A arg0, final B arg1, final C arg2); 35 | } 36 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/EventTranslatorTwoArg.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | /** 19 | * Implementations translate another data representations into events claimed from the {@link RingBuffer} 20 | * 21 | * @param event implementation storing the data for sharing during exchange or parallel coordination of an event. 22 | * @see EventTranslator 23 | */ 24 | public interface EventTranslatorTwoArg { 25 | /** 26 | * Translate a data representation into fields set in given event 27 | * 28 | * @param event into which the data should be translated. 29 | * @param sequence that is assigned to event. 30 | * @param arg0 The first user specified argument to the translator 31 | * @param arg1 The second user specified argument to the translator 32 | */ 33 | void translateTo(final T event, long sequence, final A arg0, final B arg1); 34 | } 35 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/EventTranslatorVararg.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | /** 19 | * Implementations translate another data representations into events claimed from the {@link RingBuffer} 20 | * 21 | * @param event implementation storing the data for sharing during exchange or parallel coordination of an event. 22 | * @see EventTranslator 23 | */ 24 | public interface EventTranslatorVararg { 25 | /** 26 | * Translate a data representation into fields set in given event 27 | * 28 | * @param event into which the data should be translated. 29 | * @param sequence that is assigned to event. 30 | * @param args The array of user arguments. 31 | */ 32 | void translateTo(final T event, long sequence, final Object... args); 33 | } 34 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/InsufficientCapacityException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | /** 19 | *

Exception thrown when it is not possible to insert a value into 20 | * the ring buffer without it wrapping the consuming sequences. Used 21 | * specifically when claiming with the {@link RingBuffer#tryNext()} call. 22 | *

23 | *

For efficiency this exception will not have a stack trace. 24 | *

25 | */ 26 | @SuppressWarnings("serial") 27 | public final class InsufficientCapacityException extends Exception { 28 | public static final InsufficientCapacityException INSTANCE = new InsufficientCapacityException(); 29 | 30 | private InsufficientCapacityException() { 31 | // Singleton 32 | } 33 | 34 | @Override 35 | public synchronized Throwable fillInStackTrace() { 36 | return this; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/LifecycleAware.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | /** 19 | * Implement this interface in your {@link EventHandler} to be notified when a thread for the 20 | * {@link BatchEventProcessor} starts and shuts down. 21 | */ 22 | public interface LifecycleAware { 23 | /** 24 | * Called once on thread start before first event is available. 25 | */ 26 | void onStart(); 27 | 28 | /** 29 | *

Called once just before the thread is shutdown.

30 | *

31 | * Sequence event processing will already have stopped before this method is called. No events will 32 | * be processed after this message. 33 | */ 34 | void onShutdown(); 35 | } 36 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/SequenceReportingEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | /** 19 | * Used by the {@link BatchEventProcessor} to set a callback allowing the {@link EventHandler} to notify 20 | * when it has finished consuming an event if this happens after the {@link EventHandler#onEvent(Object, long, boolean)} call. 21 | *

22 | * Typically this would be used when the handler is performing some sort of batching operation such as writing to an IO 23 | * device; after the operation has completed, the implementation should call {@link Sequence#set} to update the 24 | * sequence and allow other processes that are dependent on this handler to progress. 25 | * 26 | * @param event implementation storing the data for sharing during exchange or parallel coordination of an event. 27 | */ 28 | public interface SequenceReportingEventHandler extends EventHandler { 29 | /** 30 | * Call by the {@link BatchEventProcessor} to setup the callback. 31 | * 32 | * @param sequenceCallback callback on which to notify the {@link BatchEventProcessor} that the sequence has progressed. 33 | */ 34 | void setSequenceCallback(final Sequence sequenceCallback); 35 | } 36 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/TimeoutException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | @SuppressWarnings("serial") 19 | public final class TimeoutException extends Exception { 20 | public static final TimeoutException INSTANCE = new TimeoutException(); 21 | 22 | private TimeoutException() { 23 | // Singleton 24 | } 25 | 26 | @Override 27 | public synchronized Throwable fillInStackTrace() { 28 | return this; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/TimeoutHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | public interface TimeoutHandler { 19 | void onTimeout(long sequence) throws Exception; 20 | } 21 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/WorkHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor; 17 | 18 | /** 19 | * Callback interface to be implemented for processing units of work as they become available in the {@link RingBuffer}. 20 | * 21 | * @param event implementation storing the data for sharing during exchange or parallel coordination of an event. 22 | * @see WorkerPool 23 | */ 24 | public interface WorkHandler { 25 | /** 26 | * Callback to indicate a unit of work needs to be processed. 27 | * 28 | * @param event published to the {@link RingBuffer} 29 | * @throws Exception if the {@link WorkHandler} would like the exception handled further up the chain. 30 | */ 31 | void onEvent(T event) throws Exception; 32 | } 33 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/dsl/ConsumerInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor.dsl; 17 | 18 | import com.alipay.disruptor.Sequence; 19 | import com.alipay.disruptor.SequenceBarrier; 20 | 21 | import java.util.concurrent.Executor; 22 | 23 | interface ConsumerInfo { 24 | Sequence[] getSequences(); 25 | 26 | SequenceBarrier getBarrier(); 27 | 28 | boolean isEndOfChain(); 29 | 30 | void start(Executor executor); 31 | 32 | void halt(); 33 | 34 | void markAsUsedInBarrier(); 35 | 36 | boolean isRunning(); 37 | } 38 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/dsl/EventProcessorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor.dsl; 17 | 18 | import com.alipay.disruptor.EventProcessor; 19 | import com.alipay.disruptor.RingBuffer; 20 | import com.alipay.disruptor.Sequence; 21 | 22 | /** 23 | * A factory interface to make it possible to include custom event processors in a chain: 24 | * 25 | *


26 |  * disruptor.handleEventsWith(handler1).then((ringBuffer, barrierSequences) -> new CustomEventProcessor(ringBuffer, barrierSequences));
27 |  * 
28 | */ 29 | public interface EventProcessorFactory { 30 | 31 | /** 32 | * Create a new event processor that gates on barrierSequences. 33 | * @param ringBuffer ringBuffer 34 | * @param barrierSequences the sequences to gate on 35 | * @return a new EventProcessor that gates on barrierSequences before processing events 36 | */ 37 | EventProcessor createEventProcessor(RingBuffer ringBuffer, Sequence[] barrierSequences); 38 | } 39 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/dsl/ExceptionHandlerWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor.dsl; 17 | 18 | import com.alipay.disruptor.ExceptionHandler; 19 | import com.alipay.disruptor.FatalExceptionHandler; 20 | 21 | public class ExceptionHandlerWrapper implements ExceptionHandler { 22 | private ExceptionHandler delegate = new FatalExceptionHandler(); 23 | 24 | public void switchTo(final ExceptionHandler exceptionHandler) { 25 | this.delegate = exceptionHandler; 26 | } 27 | 28 | @Override 29 | public void handleEventException(final Throwable ex, final long sequence, final T event) { 30 | delegate.handleEventException(ex, sequence, event); 31 | } 32 | 33 | @Override 34 | public void handleOnStartException(final Throwable ex) { 35 | delegate.handleOnStartException(ex); 36 | } 37 | 38 | @Override 39 | public void handleOnShutdownException(final Throwable ex) { 40 | delegate.handleOnShutdownException(ex); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/dsl/ProducerType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor.dsl; 17 | 18 | /** 19 | * Defines producer types to support creation of RingBuffer with correct sequencer and publisher. 20 | */ 21 | public enum ProducerType { 22 | /** 23 | * Create a RingBuffer with a single event publisher to the RingBuffer 24 | */ 25 | SINGLE, 26 | 27 | /** 28 | * Create a RingBuffer supporting multiple event publishers to the one RingBuffer 29 | */ 30 | MULTI 31 | } 32 | -------------------------------------------------------------------------------- /tracer-core/src/main/java/com/alipay/disruptor/util/DaemonThreadFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 LMAX Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alipay.disruptor.util; 17 | 18 | import java.util.concurrent.ThreadFactory; 19 | 20 | /** 21 | * Access to a ThreadFactory instance. All threads are created with setDaemon(true). 22 | */ 23 | public enum DaemonThreadFactory implements ThreadFactory { 24 | INSTANCE; 25 | 26 | @Override 27 | public Thread newThread(final Runnable r) { 28 | Thread t = new Thread(r); 29 | t.setDaemon(true); 30 | return t; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tracer-core/src/main/resources/tracer/log-codes.properties: -------------------------------------------------------------------------------- 1 | 01-00001=SpanContext created error when server received and root SpanContext created. 2 | 01-00002=Failed to get tracer sampler strategy. 3 | 01-00003=Tracer tags unsupported type [ %s ]. 4 | 01-00004=Unable to get log time of log file %s, the reason is %s. 5 | 01-00005=Fail to delete log file: %s. 6 | 01-00006=Failed to clean up log file. 7 | 01-00007=No Settings for file rolling suffix's model. 8 | 01-00008=Failed to closing the output stream. 9 | 01-00009=Failed to rename [ %s ] to [ %s ]. 10 | 01-00010=the value for %s is not the type of map. 11 | 01-00011=Log Type can't be empty when report. 12 | 01-00012=Span tags unsupported type [ %s ]. 13 | 01-00013=Current stage has no span exist in SofaTracerContext. 14 | 01-00014=Cannot set tag to component. current component is [ %s ]. 15 | 01-00015=Parse connnect url error 16 | -------------------------------------------------------------------------------- /tracer-core/src/main/resources/tracer/log-codes_zh_CN.properties: -------------------------------------------------------------------------------- 1 | 01-00001=SpanContext created error when server received and root SpanContext created. 2 | 01-00002=Failed to get tracer sampler strategy. 3 | 01-00003=Tracer tags unsupported type [ %s ]. 4 | 01-00004=Unable to get log time of log file %s, the reason is %s. 5 | 01-00005=Fail to delete log file: %s. 6 | 01-00006=Failed to clean up log file. 7 | 01-00007=No Settings for file rolling suffix's model. 8 | 01-00008=Failed to closing the output stream. 9 | 01-00009=Failed to rename [ %s ] to [ %s ]. 10 | 01-00010=the value for %s is not the type of map. 11 | 01-00011=Log Type can't be empty when report. 12 | 01-00012=Span tags unsupported type [ %s ]. 13 | 01-00013=Current stage has no span exist in SofaTracerContext. 14 | 01-00014=Cannot set tag to component. current component is [ %s ]. 15 | 01-00015=Parse connnect url error -------------------------------------------------------------------------------- /tracer-core/src/test/java/com/alipay/common/tracer/core/appender/manager/ManagerTestUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.appender.manager; 18 | 19 | import com.alipay.common.tracer.core.SofaTracer; 20 | import com.alipay.common.tracer.core.context.span.SofaTracerSpanContext; 21 | import com.alipay.common.tracer.core.span.SofaTracerSpan; 22 | 23 | /** 24 | * 25 | * @author liangen 26 | * @version $Id: ManagerTestUtil.java, v 0.1 October 23, 2017 8:34 PM liangen Exp $ 27 | */ 28 | public class ManagerTestUtil { 29 | 30 | public static SofaTracerSpan createSofaTracerSpan(int sequence) { 31 | 32 | SofaTracerSpanContext spanContext = new SofaTracerSpanContext("traceID" + sequence, 33 | "spanId", "parentId", false); 34 | SofaTracerSpan span = new SofaTracerSpan(new SofaTracer.Builder("tracerType").build(), 35 | System.currentTimeMillis(), "callServiceName", spanContext, null); 36 | span.setLogType("logType" + sequence); 37 | 38 | return span; 39 | } 40 | } -------------------------------------------------------------------------------- /tracer-core/src/test/java/com/alipay/common/tracer/core/samplers/SamplerPropertiesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.samplers; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Before; 21 | import org.junit.Test; 22 | 23 | /** 24 | * @description: [test unit for SamplerProperties] 25 | * @email: 26 | * @author: guolei.sgl 27 | * @date: 18/7/25 28 | */ 29 | public class SamplerPropertiesTest { 30 | 31 | SamplerProperties samplerProperties; 32 | 33 | @Before 34 | public void before() { 35 | samplerProperties = new SamplerProperties(); 36 | 37 | } 38 | 39 | @Test 40 | public void getPercentage() { 41 | Assert.assertTrue(samplerProperties.getPercentage() == 100); 42 | } 43 | 44 | @Test 45 | public void setPercentage() { 46 | samplerProperties.setPercentage(20); 47 | Assert.assertTrue(samplerProperties.getPercentage() == 20); 48 | } 49 | } -------------------------------------------------------------------------------- /tracer-core/src/test/java/com/alipay/common/tracer/core/tracertest/encoder/ServerSpanEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.tracertest.encoder; 18 | 19 | import com.alipay.common.tracer.core.appender.encoder.SpanEncoder; 20 | import com.alipay.common.tracer.core.span.SofaTracerSpan; 21 | 22 | /** 23 | * ClientSpanEncoder 24 | * 25 | * @author yangguanchao 26 | * @since 2017/07/01 27 | */ 28 | public class ServerSpanEncoder extends ClientSpanEncoder implements SpanEncoder { 29 | } 30 | -------------------------------------------------------------------------------- /tracer-core/src/test/java/com/alipay/common/tracer/core/utils/DateUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.core.utils; 18 | 19 | import org.junit.Test; 20 | 21 | import java.util.Date; 22 | 23 | import static junit.framework.TestCase.assertTrue; 24 | 25 | /** 26 | * @author zhile 27 | * @version : DateUtilsTest.java, v 0.1 2021年10月08日 下午3:47 zhile Exp $ 28 | */ 29 | public class DateUtilsTest { 30 | 31 | @Test 32 | public void testDiffNextMinute() { 33 | long diff = DateUtils.diffNextMinute(new Date()); 34 | assertTrue(diff > 0); 35 | } 36 | } -------------------------------------------------------------------------------- /tracer-core/src/test/java/com/alipay/common/tracer/util/MockDesensitizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.util; 18 | 19 | /** 20 | *

created at 2021/4/12 21 | * 22 | * @author xiangfeng.xzc 23 | */ 24 | class MockDesensitizer implements Desensitizer { 25 | private final boolean exception; 26 | 27 | MockDesensitizer() { 28 | this(false); 29 | } 30 | 31 | MockDesensitizer(boolean exception) { 32 | this.exception = exception; 33 | } 34 | 35 | @Override 36 | public String desensitize(String str) { 37 | if (exception) { 38 | throw new IllegalStateException("exception is true"); 39 | } 40 | return "mocked"; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /tracer-core/src/test/java/com/alipay/disruptor/BusySpinWaitStrategyTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.disruptor; 18 | 19 | import org.junit.Test; 20 | 21 | import static com.alipay.disruptor.support.WaitStrategyTestUtil.assertWaitForWithDelayOf; 22 | 23 | /** 24 | * @description: [test for BusySpinWaitStrategy] 25 | * @email: 26 | * @author: guolei.sgl 27 | * @date: 18/8/1 28 | */ 29 | public class BusySpinWaitStrategyTest { 30 | @Test 31 | public void shouldWaitForValue() throws Exception { 32 | assertWaitForWithDelayOf(50, new BusySpinWaitStrategy()); 33 | } 34 | } -------------------------------------------------------------------------------- /tracer-core/src/test/java/com/alipay/disruptor/FixedSequenceGroupTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.disruptor; 18 | 19 | import org.junit.Test; 20 | 21 | import static org.hamcrest.CoreMatchers.is; 22 | import static org.junit.Assert.assertThat; 23 | 24 | /** 25 | * @description: [test for FixedSequenceGroup] 26 | * @email: 27 | * @author: guolei.sgl 28 | * @date: 18/8/1 29 | */ 30 | public class FixedSequenceGroupTest { 31 | @Test 32 | public void shouldReturnMinimumOf2Sequences() throws Exception { 33 | Sequence sequence1 = new Sequence(34); 34 | Sequence sequnece2 = new Sequence(47); 35 | Sequence group = new FixedSequenceGroup(new Sequence[] { sequence1, sequnece2 }); 36 | 37 | assertThat(group.get(), is(34L)); 38 | sequence1.set(35); 39 | assertThat(group.get(), is(35L)); 40 | sequence1.set(48); 41 | assertThat(group.get(), is(47L)); 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /tracer-core/src/test/java/com/alipay/disruptor/IgnoreExceptionHandlerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.disruptor; 18 | 19 | import com.alipay.disruptor.support.TestEvent; 20 | import org.junit.Test; 21 | 22 | /** 23 | * @description: [test for IgnoreExceptionHandler] 24 | * @email: 25 | * @author: guolei.sgl 26 | * @date: 18/8/1 27 | */ 28 | public class IgnoreExceptionHandlerTest { 29 | 30 | @Test 31 | public void shouldHandleAndIgnoreException() { 32 | final Exception ex = new Exception(); 33 | final TestEvent event = new TestEvent(); 34 | ExceptionHandler exceptionHandler = new IgnoreExceptionHandler(); 35 | exceptionHandler.handleEventException(ex, 0L, event); 36 | } 37 | } -------------------------------------------------------------------------------- /tracer-core/src/test/java/com/alipay/disruptor/SleepingWaitStrategyTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.disruptor; 18 | 19 | import org.junit.Test; 20 | 21 | import static com.alipay.disruptor.support.WaitStrategyTestUtil.assertWaitForWithDelayOf; 22 | 23 | /** 24 | * @description: [test for SleepingWaitStrategy] 25 | * @email: 26 | * @author: guolei.sgl 27 | * @date: 18/8/1 28 | */ 29 | public class SleepingWaitStrategyTest { 30 | @Test 31 | public void shouldWaitForValue() throws Exception { 32 | assertWaitForWithDelayOf(50, new SleepingWaitStrategy()); 33 | } 34 | } -------------------------------------------------------------------------------- /tracer-core/src/test/java/com/alipay/disruptor/YieldingWaitStrategyTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.disruptor; 18 | 19 | import org.junit.Test; 20 | 21 | import static com.alipay.disruptor.support.WaitStrategyTestUtil.assertWaitForWithDelayOf; 22 | 23 | /** 24 | * @description: [test for YieldingWaitStrategy] 25 | * @email: 26 | * @author: guolei.sgl 27 | * @date: 18/8/1 28 | */ 29 | public class YieldingWaitStrategyTest { 30 | @Test 31 | public void shouldWaitForValue() throws Exception { 32 | assertWaitForWithDelayOf(50, new YieldingWaitStrategy()); 33 | } 34 | } -------------------------------------------------------------------------------- /tracer-core/src/test/java/com/alipay/disruptor/support/DummyEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.disruptor.support; 18 | 19 | import com.alipay.disruptor.EventHandler; 20 | import com.alipay.disruptor.LifecycleAware; 21 | 22 | /** 23 | * @description: [support for test handler] 24 | * @email: 25 | * @author: guolei.sgl 26 | * @date: 18/8/1 27 | */ 28 | public class DummyEventHandler implements EventHandler, LifecycleAware { 29 | public int startCalls = 0; 30 | public int shutdownCalls = 0; 31 | public T lastEvent; 32 | public long lastSequence; 33 | 34 | @Override 35 | public void onStart() { 36 | startCalls++; 37 | } 38 | 39 | @Override 40 | public void onShutdown() { 41 | shutdownCalls++; 42 | } 43 | 44 | @Override 45 | public void onEvent(T event, long sequence, boolean endOfBatch) throws Exception { 46 | lastEvent = event; 47 | lastSequence = sequence; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /tracer-core/src/test/java/com/alipay/disruptor/support/DummySequenceBarrier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.disruptor.support; 18 | 19 | import com.alipay.disruptor.AlertException; 20 | import com.alipay.disruptor.SequenceBarrier; 21 | 22 | /** 23 | * @description: [support for test strategy] 24 | * @email: 25 | * @author: guolei.sgl 26 | * @date: 18/8/1 27 | */ 28 | public class DummySequenceBarrier implements SequenceBarrier { 29 | @Override 30 | public long waitFor(long sequence) throws AlertException, InterruptedException { 31 | return 0; 32 | } 33 | 34 | @Override 35 | public long getCursor() { 36 | return 0; 37 | } 38 | 39 | @Override 40 | public boolean isAlerted() { 41 | return false; 42 | } 43 | 44 | @Override 45 | public void alert() { 46 | } 47 | 48 | @Override 49 | public void clearAlert() { 50 | } 51 | 52 | @Override 53 | public void checkAlert() throws AlertException { 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /tracer-core/src/test/java/com/alipay/disruptor/support/TestEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.disruptor.support; 18 | 19 | import com.alipay.disruptor.EventFactory; 20 | 21 | /** 22 | * @description: [support for test disruptor] 23 | * @email: 24 | * @author: guolei.sgl 25 | * @date: 18/8/1 26 | */ 27 | public class TestEvent { 28 | @Override 29 | public String toString() { 30 | return "Test Event"; 31 | } 32 | 33 | public static final EventFactory EVENT_FACTORY = new EventFactory() { 34 | public TestEvent newInstance() { 35 | return new TestEvent(); 36 | } 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /tracer-core/src/test/resources/sofa.tracer.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | testProperty1=test1 19 | testProperty2=test2 20 | testIntegerProperty1=1 -------------------------------------------------------------------------------- /tracer-extensions/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | tracer-all-parent 6 | com.alipay.sofa 7 | 3.1.10 8 | 9 | 10 | tracer-extensions 11 | 12 | 13 | 14 | 15 | com.alipay.sofa 16 | tracer-core 17 | 18 | 19 | 20 | org.slf4j 21 | slf4j-api 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /tracer-extensions/src/main/java/com/alipay/common/tracer/extensions/log/constants/MDCKeyConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.extensions.log.constants; 18 | 19 | /** 20 | * 负责管理MDC中需要存入的key值常量 21 | * @author luoguimu123 22 | * @version $Id: MDCKeyConstants.java, v 0.1 2017年08月07日 上午8:44 luoguimu123 Exp $ 23 | */ 24 | public class MDCKeyConstants { 25 | 26 | public static final String MDC_TRACEID = "SOFA-TraceId"; 27 | 28 | public static final String MDC_SPANID = "SOFA-SpanId"; 29 | 30 | public static final String MDC_PARENTSPANID = "SOFA-ParentSpanId"; 31 | 32 | } -------------------------------------------------------------------------------- /tracer-extensions/src/main/resources/META-INF/services/com.alipay.common.tracer.core.extensions.SpanExtension: -------------------------------------------------------------------------------- 1 | com.alipay.common.tracer.extensions.log.MDCSpanExtension -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/main/java/com/alipay/sofa/tracer/boot/datasource/properties/SofaTracerDataSourceProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.boot.datasource.properties; 18 | 19 | import org.springframework.boot.context.properties.ConfigurationProperties; 20 | 21 | /** 22 | * @author qilong.zql 18/9/4-PM 1:41 23 | */ 24 | @ConfigurationProperties("com.alipay.sofa.tracer.datasource") 25 | public class SofaTracerDataSourceProperties { 26 | private boolean enable; 27 | 28 | public boolean isEnable() { 29 | return enable; 30 | } 31 | 32 | public void setEnable(boolean enable) { 33 | this.enable = enable; 34 | } 35 | } -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/main/java/com/alipay/sofa/tracer/boot/flexible/aop/TracerAnnotationClassAdvisor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.boot.flexible.aop; 18 | 19 | import org.aopalliance.aop.Advice; 20 | import org.aopalliance.intercept.MethodInterceptor; 21 | import org.springframework.aop.Pointcut; 22 | import org.springframework.aop.support.AbstractPointcutAdvisor; 23 | 24 | /** 25 | * @author: guolei.sgl (guolei.sgl@antfin.com) 2019/8/9 3:17 PM 26 | * @since: 27 | **/ 28 | public class TracerAnnotationClassAdvisor extends AbstractPointcutAdvisor { 29 | 30 | private Advice advice; 31 | 32 | private Pointcut pointcut; 33 | 34 | public TracerAnnotationClassAdvisor(MethodInterceptor interceptor) { 35 | this.advice = interceptor; 36 | this.pointcut = new TracerAnnotationClassPointcut(); 37 | } 38 | 39 | @Override 40 | public Pointcut getPointcut() { 41 | return this.pointcut; 42 | } 43 | 44 | @Override 45 | public Advice getAdvice() { 46 | return this.advice; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/main/java/com/alipay/sofa/tracer/boot/flexible/processor/MethodInvocationProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.boot.flexible.processor; 18 | 19 | import com.alipay.sofa.tracer.plugin.flexible.annotations.Tracer; 20 | import org.aopalliance.intercept.MethodInvocation; 21 | 22 | /** 23 | * @author: guolei.sgl (guolei.sgl@antfin.com) 2019/8/9 2:50 PM 24 | * @since: 25 | **/ 26 | public interface MethodInvocationProcessor { 27 | 28 | /** 29 | * proxy method 30 | * @param invocation 31 | * @param tracerSpan 32 | * @return 33 | * @throws Throwable 34 | */ 35 | Object process(MethodInvocation invocation, Tracer tracerSpan) throws Throwable; 36 | } 37 | -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/main/java/com/alipay/sofa/tracer/boot/redis/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | /** 18 | * @author: guolei.sgl (guolei.sgl@antfin.com) 2019/11/19 7:59 PM 19 | * @since: 20 | **/ 21 | package com.alipay.sofa.tracer.boot.redis; -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/main/java/com/alipay/sofa/tracer/boot/zipkin/properties/ZipkinSofaTracerSamplerProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.boot.zipkin.properties; 18 | 19 | import com.alipay.common.tracer.core.samplers.SamplerProperties; 20 | import org.springframework.boot.context.properties.ConfigurationProperties; 21 | 22 | /** 23 | * ZipkinSofaTracerSamplerProperties 24 | * 25 | * @author yangguanchao 26 | * @since 2018/05/01 27 | */ 28 | @ConfigurationProperties("com.alipay.sofa.tracer.sampler") 29 | public class ZipkinSofaTracerSamplerProperties extends SamplerProperties { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | com.alipay.sofa.tracer.boot.configuration.SofaTracerAutoConfiguration,\ 3 | com.alipay.sofa.tracer.boot.springmvc.configuration.OpenTracingSpringMvcAutoConfiguration,\ 4 | com.alipay.sofa.tracer.boot.zipkin.configuration.ZipkinSofaTracerAutoConfiguration,\ 5 | com.alipay.sofa.tracer.boot.datasource.configuration.SofaTracerDataSourceAutoConfiguration,\ 6 | com.alipay.sofa.tracer.boot.springcloud.configuration.SofaTracerFeignClientAutoConfiguration,\ 7 | com.alipay.sofa.tracer.boot.message.configuration.SpringMessageAutoConfiguration,\ 8 | com.alipay.sofa.tracer.boot.flexible.configuration.TracerAnnotationConfiguration,\ 9 | com.alipay.sofa.tracer.boot.mongodb.configuration.SofaTracerMongoAutoConfiguration,\ 10 | com.alipay.sofa.tracer.boot.rabbitmq.configuration.SofaTracerRabbitMqConfiguration,\ 11 | com.alipay.sofa.tracer.boot.kafka.configuration.SofaTracerKafkaAutoConfiguration,\ 12 | com.alipay.sofa.tracer.boot.resttemplate.SofaTracerRestTemplateConfiguration,\ 13 | com.alipay.sofa.tracer.boot.redis.configuration.SofaTracerRedisConfiguration 14 | org.springframework.context.ApplicationListener=\ 15 | com.alipay.sofa.tracer.boot.listener.SofaTracerConfigurationListener -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/TestUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.boot; 18 | 19 | /** 20 | * @author qilong.zql 21 | * @since 2.2.2 22 | */ 23 | public class TestUtil { 24 | public static void waitForAsyncLog() throws InterruptedException { 25 | // wait flush log to file... (500ms is just expected time) 26 | Thread.sleep(500); 27 | } 28 | } -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/ConfigurationHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.boot.base; 18 | 19 | import com.alipay.sofa.tracer.boot.properties.SofaTracerProperties; 20 | 21 | /** 22 | * @author qilong.zql 23 | * @since 2.2.2 24 | */ 25 | public class ConfigurationHolder { 26 | public static SofaTracerProperties sofaTracerProperties; 27 | 28 | public static SofaTracerProperties getSofaTracerProperties() { 29 | return sofaTracerProperties; 30 | } 31 | 32 | public static void setSofaTracerProperties(SofaTracerProperties sofaTracerProperties) { 33 | ConfigurationHolder.sofaTracerProperties = sofaTracerProperties; 34 | } 35 | } -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/controller/TestService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.boot.base.controller; 18 | 19 | import com.alipay.sofa.tracer.plugin.flexible.annotations.Tracer; 20 | import org.springframework.stereotype.Service; 21 | 22 | /** 23 | * @author: guolei.sgl (guolei.sgl@antfin.com) 2019/8/3 10:27 AM 24 | * @since: 25 | **/ 26 | @Service 27 | public class TestService { 28 | 29 | /** 30 | * 生效 31 | * @return 32 | */ 33 | @Tracer 34 | public String testTraceAnnotation() { 35 | return "tracer"; 36 | } 37 | 38 | @Tracer 39 | public String testTraceAnnotationException() { 40 | throw new RuntimeException("testException"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/datasource/DataSourceTracerDisableTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.boot.datasource; 18 | 19 | import com.alipay.sofa.tracer.boot.base.AbstractTestBase; 20 | import com.zaxxer.hikari.HikariDataSource; 21 | import org.junit.Assert; 22 | import org.junit.Test; 23 | import org.springframework.beans.factory.annotation.Autowired; 24 | import org.springframework.test.context.ActiveProfiles; 25 | 26 | import javax.sql.DataSource; 27 | 28 | /**DataSourceUtils 29 | * @author qilong.zql 30 | * @sicne 2.2.0 31 | */ 32 | @ActiveProfiles("datasource") 33 | public class DataSourceTracerDisableTest extends AbstractTestBase { 34 | 35 | @Autowired 36 | private DataSource simpleDataSource; 37 | 38 | @Test 39 | public void testDataSource() { 40 | Assert.assertTrue(simpleDataSource instanceof HikariDataSource); 41 | } 42 | } -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/opentracing/profiles/init/InitProfileTracerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.sofa.tracer.boot.opentracing.profiles.init; 18 | 19 | import com.alipay.sofa.tracer.boot.base.AbstractTestBase; 20 | import org.junit.Test; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.core.env.Environment; 23 | import org.springframework.test.context.ActiveProfiles; 24 | 25 | import static org.junit.Assert.assertEquals; 26 | 27 | /** 28 | * InitProfileTracerTest 29 | * 30 | * @author yangguanchao 31 | * @since 2018/05/08 32 | */ 33 | @ActiveProfiles("init") 34 | public class InitProfileTracerTest extends AbstractTestBase { 35 | 36 | @Autowired 37 | private Environment environment; 38 | 39 | @Test 40 | public void initPropertyTest() throws Exception { 41 | String loggingPath = environment.getProperty("logging.path1"); 42 | assertEquals("./logs", loggingPath); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.context.ApplicationListener=com.alipay.sofa.tracer.boot.base.ConfigurationHolderListener -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/resources/application-async.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | spring.application.name=SpringMvcAsyncServlet 19 | 20 | #default 60s and now reset to 1 21 | com.alipay.sofa.tracer.statLogInterval=1 22 | -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/resources/application-config.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=test-app-name 2 | com.alipay.sofa.tracer.disableDigestLog=true 3 | com.alipay.sofa.tracer.disableConfiguration[k1]=v1 4 | com.alipay.sofa.tracer.disableConfiguration[k2]=v2 5 | com.alipay.sofa.tracer.tracerGlobalRollingPolicy='.'yyyy-MM-dd_HH 6 | com.alipay.sofa.tracer.tracerGlobalLogReserveDay=1 7 | com.alipay.sofa.tracer.statLogInterval=1 8 | com.alipay.sofa.tracer.baggageMaxLength=1 9 | logging.path=./logs 10 | -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/resources/application-configerror.properties: -------------------------------------------------------------------------------- 1 | com.alipay.sofa.tracer.test.xxx=xxx -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/resources/application-datasource.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=test-app-name 2 | com.alipay.sofa.tracer.datasource.enable=false -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/resources/application-feign.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=feign-client 2 | server.port=8085 -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/resources/application-flexible.properties: -------------------------------------------------------------------------------- 1 | com.alipay.sofa.tracer.reporter-name=com.alipay.sofa.tracer.boot.flexible.TestReporter 2 | spring.application.name=flexibel-app -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/resources/application-init.properties: -------------------------------------------------------------------------------- 1 | logging.path1=./logs 2 | spring.application.name=test-app-name -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/resources/application-json.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=SpringMvcJsonOutput 2 | 3 | #默认 60 秒统计日志输出一次,这里设置为 1s,方便测试 4 | com.alipay.sofa.tracer.statLogInterval=1 5 | -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/resources/application-non-json.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | spring.application.name=test-mvc 19 | com.alipay.sofa.tracer.jsonOutput=false 20 | logging.path=/home/admin/logs 21 | -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/resources/application-redis.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=redis-test -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/resources/application-ribbon.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=ribbon-client 2 | server.port=8890 -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/resources/application-tracer.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=test-app-name 2 | # disable 3 | com.alipay.sofa.tracer.disableDigestLog=false 4 | # map 5 | com.alipay.sofa.tracer.disableConfiguration[logType]=true 6 | com.alipay.sofa.tracer.disableConfiguration[component-digest.log]=true 7 | com.alipay.sofa.tracer.disableConfiguration[spring-mvc-digest.log]=true 8 | com.alipay.sofa.tracer.tracerGlobalRollingPolicy=.yyyy-MM-dd 9 | com.alipay.sofa.tracer.tracerGlobalLogReserveDay=8 10 | # stat interval 70s 11 | com.alipay.sofa.tracer.statLogInterval=70 12 | com.alipay.sofa.tracer.baggageMaxLength=2048 -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/resources/application-zipkin.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=zipkin-client 2 | com.alipay.sofa.tracer.springmvc.jsonOutput=false 3 | com.alipay.sofa.tracer.zipkin.enabled=true 4 | com.alipay.sofa.tracer.zipkin.baseUrl=http://localhost:9411 5 | com.alipay.sofa.tracer.zipkin.gzipped=true -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=test-app-name 2 | spring.datasource.url=jdbc:mysql://localhost:3306/sofa 3 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 4 | spring.datasource.username=xxxx 5 | spring.datasource.password=xxxx 6 | spring.datasource.type=com.zaxxer.hikari.HikariDataSource 7 | spring.datasource.hikari.minimum-idle=3 8 | spring.datasource.hikari.maximum-pool-size=5 9 | spring.datasource.hikari.idle-timeout=30000 10 | spring.datasource.hikari.pool-name=SofaHikariCPDatasource 11 | spring.datasource.hikari.max-lifetime=1800000 12 | spring.datasource.hikari.connection-timeout=30000 13 | spring.datasource.hikari.connection-test-query=SELECT 1 14 | -------------------------------------------------------------------------------- /tracer-sofa-boot-starter/src/test/resources/hikariDataSource.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tracer-test/core-test/src/test/java/com/alipay/common/tracer/test/TestUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alipay.common.tracer.test; 18 | 19 | /** 20 | * @author qilong.zql 21 | * @since 2.2.2 22 | */ 23 | public class TestUtil { 24 | public static void waitForAsyncLog() throws InterruptedException { 25 | // wait flush log to file... (500ms is just expected time) 26 | Thread.sleep(500); 27 | } 28 | } -------------------------------------------------------------------------------- /tracer-test/log4j-test/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | tracer-all-parent 6 | com.alipay.sofa 7 | 3.1.10 8 | ../../pom.xml 9 | 10 | 11 | sofa-tracer-log4j-test 12 | 13 | 14 | 15 | 16 | com.alipay.sofa 17 | tracer-extensions 18 | 19 | 20 | 21 | junit 22 | junit 23 | 4.13.1 24 | 25 | 26 | 27 | org.slf4j 28 | slf4j-log4j12 29 | 30 | 31 | 32 | 33 | com.github.stefanbirkner 34 | system-rules 35 | 1.5.0 36 | test 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.apache.maven.plugins 45 | maven-deploy-plugin 46 | 2.8.2 47 | 48 | true 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /tracer-test/log4j-test/src/test/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | log4j.rootLogger = INFO,system.out 19 | log4j.appender.system.out=org.apache.log4j.ConsoleAppender 20 | log4j.appender.system.out.layout=org.apache.log4j.PatternLayout 21 | log4j.appender.system.out.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %5p [%X{SOFA-TraceId}, %X{SOFA-SpanId}, %X{SOFA-ParentSpanId}] %t lgm ---- %m%n -------------------------------------------------------------------------------- /tracer-test/log4j2-test/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %t 5 | %xwEx 6 | %5p 7 | %d{yyyy-MM-dd HH:mm:ss.SSS} %5p lgm %X{SOFA-TraceId} %X{SOFA-SpanId} ---- %m%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /tracer-test/logback-test/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{yyyy-MM-dd HH:mm:ss.SSS} %5p lgm %X{SOFA-TraceId} %X{SOFA-SpanId} ---- %m%n 7 | utf8 8 | 9 | 10 | 11 | 12 | 13 | 14 | --------------------------------------------------------------------------------