Skip to content

Commit 3c6a4e8

Browse files
Merge pull request #13 from alipay/master
Merge
2 parents e8fb6c9 + cc1eefe commit 3c6a4e8

File tree

13 files changed

+41
-44
lines changed

13 files changed

+41
-44
lines changed

tracer-core/src/main/java/com/alipay/common/tracer/core/appender/TracerLogRootDeamon.java renamed to tracer-core/src/main/java/com/alipay/common/tracer/core/appender/TracerLogRootDaemon.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
import java.nio.charset.Charset;
2626

2727
/**
28-
* TracerLogRootDeamon
28+
* TracerLogRootDaemon
2929
*
3030
* 不从配置项目获取,直接从系统属性获取
3131
*
3232
* @author yangguanchao
3333
* @since 2017/06/25
3434
*/
35-
public class TracerLogRootDeamon {
35+
public class TracerLogRootDaemon {
3636

3737
/***
3838
* 是否添加 pid 到 log path

tracer-core/src/main/java/com/alipay/common/tracer/core/appender/file/AbstractRollingFileAppender.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.alipay.common.tracer.core.appender.file;
1818

1919
import com.alipay.common.tracer.core.appender.TraceAppender;
20-
import com.alipay.common.tracer.core.appender.TracerLogRootDeamon;
20+
import com.alipay.common.tracer.core.appender.TracerLogRootDaemon;
2121
import com.alipay.common.tracer.core.appender.self.SelfLog;
2222

2323
import java.io.BufferedOutputStream;
@@ -63,7 +63,7 @@ public AbstractRollingFileAppender(String file, boolean append) {
6363
}
6464

6565
public AbstractRollingFileAppender(String file, int bufferSize, boolean append) {
66-
this.fileName = TracerLogRootDeamon.LOG_FILE_DIR + File.separator + file;
66+
this.fileName = TracerLogRootDaemon.LOG_FILE_DIR + File.separator + file;
6767
this.bufferSize = bufferSize;
6868
setFile(append);
6969
}
@@ -115,7 +115,7 @@ public void append(String log) throws IOException {
115115
}
116116
}
117117
// 无论有没有做 RollOver,都需要将输入往 bos 中写入
118-
byte[] bytes = log.getBytes(TracerLogRootDeamon.DEFAULT_CHARSET);
118+
byte[] bytes = log.getBytes(TracerLogRootDaemon.DEFAULT_CHARSET);
119119
write(bytes);
120120
}
121121
}

tracer-core/src/test/java/com/alipay/common/tracer/core/appender/LogCleanupTest.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -114,60 +114,60 @@ public void rolling_by_three_hour() throws IOException {
114114
}
115115

116116
private void generateLogFilesToBeCleanupHourly(SimpleDateFormat sdf) throws IOException {
117-
todayFile = newFile(TracerLogRootDeamon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG);
117+
todayFile = newFile(TracerLogRootDaemon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG);
118118

119119
Calendar oneHourAgo = Calendar.getInstance();
120120
oneHourAgo.add(Calendar.HOUR, -1);
121-
yesterdayFile = newFile(TracerLogRootDeamon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
121+
yesterdayFile = newFile(TracerLogRootDaemon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
122122
+ sdf.format(oneHourAgo.getTime()));
123123

124124
Calendar twoHourAgo = Calendar.getInstance();
125125
twoHourAgo.add(Calendar.HOUR, -2);
126-
twoDayAgoFile = newFile(TracerLogRootDeamon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
126+
twoDayAgoFile = newFile(TracerLogRootDaemon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
127127
+ sdf.format(twoHourAgo.getTime()));
128128

129129
Calendar threeHourAgo = Calendar.getInstance();
130130
threeHourAgo.add(Calendar.HOUR, -3);
131-
threeDayAgoFile = newFile(TracerLogRootDeamon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
131+
threeDayAgoFile = newFile(TracerLogRootDaemon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
132132
+ sdf.format(threeHourAgo.getTime()));
133133

134134
Calendar fourHourAgo = Calendar.getInstance();
135135
fourHourAgo.add(Calendar.HOUR, -4);
136-
fourDayAgoFile = newFile(TracerLogRootDeamon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
136+
fourDayAgoFile = newFile(TracerLogRootDaemon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
137137
+ sdf.format(fourHourAgo.getTime()));
138138

139139
Calendar fiveHourAgo = Calendar.getInstance();
140140
fiveHourAgo.add(Calendar.HOUR, -5);
141-
fiveDayAgoFile = newFile(TracerLogRootDeamon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
141+
fiveDayAgoFile = newFile(TracerLogRootDaemon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
142142
+ sdf.format(fiveHourAgo.getTime()));
143143
}
144144

145145
private void generateLogFilesToBeCleanup(SimpleDateFormat sdf) throws IOException {
146-
todayFile = newFile(TracerLogRootDeamon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG);
146+
todayFile = newFile(TracerLogRootDaemon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG);
147147

148148
Calendar yesterday = Calendar.getInstance();
149149
yesterday.add(Calendar.DATE, -1);
150-
yesterdayFile = newFile(TracerLogRootDeamon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
150+
yesterdayFile = newFile(TracerLogRootDaemon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
151151
+ sdf.format(yesterday.getTime()));
152152

153153
Calendar twoDayAgo = Calendar.getInstance();
154154
twoDayAgo.add(Calendar.DATE, -2);
155-
twoDayAgoFile = newFile(TracerLogRootDeamon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
155+
twoDayAgoFile = newFile(TracerLogRootDaemon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
156156
+ sdf.format(twoDayAgo.getTime()));
157157

158158
Calendar threeDayAgo = Calendar.getInstance();
159159
threeDayAgo.add(Calendar.DATE, -3);
160-
threeDayAgoFile = newFile(TracerLogRootDeamon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
160+
threeDayAgoFile = newFile(TracerLogRootDaemon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
161161
+ sdf.format(threeDayAgo.getTime()));
162162

163163
Calendar fourDayAgo = Calendar.getInstance();
164164
fourDayAgo.add(Calendar.DATE, -4);
165-
fourDayAgoFile = newFile(TracerLogRootDeamon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
165+
fourDayAgoFile = newFile(TracerLogRootDaemon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
166166
+ sdf.format(fourDayAgo.getTime()));
167167

168168
Calendar fiveDayAgo = Calendar.getInstance();
169169
fiveDayAgo.add(Calendar.DATE, -5);
170-
fiveDayAgoFile = newFile(TracerLogRootDeamon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
170+
fiveDayAgoFile = newFile(TracerLogRootDaemon.LOG_FILE_DIR + "/" + CLEAN_UP_TEST_LOG
171171
+ sdf.format(fiveDayAgo.getTime()));
172172
}
173173

tracer-core/src/test/java/com/alipay/common/tracer/core/appender/TracerLogRootDeamonTest.java renamed to tracer-core/src/test/java/com/alipay/common/tracer/core/appender/TracerLogRootDaemonTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,32 @@
2525
import static junit.framework.TestCase.assertEquals;
2626

2727
/**
28-
* TracerLogRootDeamon Tester.
28+
* TracerLogRootDaemon Tester.
2929
*
3030
* @author <guanchao.ygc>
3131
* @version 1.0
3232
* @since <pre>七月 24, 2017</pre>
3333
*/
34-
public class TracerLogRootDeamonTest {
34+
public class TracerLogRootDaemonTest {
3535

3636
@Before
3737
public void before() throws Exception {
3838

39-
System.setProperty(TracerLogRootDeamon.TRACER_APPEND_PID_TO_LOG_PATH_KEY, "true");
39+
System.setProperty(TracerLogRootDaemon.TRACER_APPEND_PID_TO_LOG_PATH_KEY, "true");
4040

4141
}
4242

4343
@After
4444
public void after() throws Exception {
45-
System.clearProperty(TracerLogRootDeamon.TRACER_APPEND_PID_TO_LOG_PATH_KEY);
45+
System.clearProperty(TracerLogRootDaemon.TRACER_APPEND_PID_TO_LOG_PATH_KEY);
4646
}
4747

4848
//@Test
4949
public void testLogRoot() {
5050
String traceLogRoot = System.getProperty("user.home") + File.separator + "logs";
5151
traceLogRoot += File.separator + "tracelog";
5252
traceLogRoot += File.separator + TracerUtils.getPID();
53-
assertEquals(TracerLogRootDeamon.LOG_FILE_DIR, traceLogRoot);
53+
assertEquals(TracerLogRootDaemon.LOG_FILE_DIR, traceLogRoot);
5454
}
5555

5656
}

tracer-core/src/test/java/com/alipay/common/tracer/core/appender/file/TimedRollingFileAppenderTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
package com.alipay.common.tracer.core.appender.file;
1818

19-
import com.alipay.common.tracer.core.appender.TracerLogRootDeamon;
19+
import com.alipay.common.tracer.core.appender.TracerLogRootDaemon;
2020
import com.alipay.common.tracer.core.base.AbstractTestBase;
2121
import com.alipay.common.tracer.core.utils.StringUtils;
2222
import org.apache.commons.io.FileUtils;
@@ -52,7 +52,7 @@ public void test() throws IOException, InterruptedException {
5252
TimeUnit.SECONDS.sleep(1);
5353
timedRollingFileAppender.append(content);
5454
timedRollingFileAppender.flush();
55-
Resource[] resources = resolver.getResources("file:" + TracerLogRootDeamon.LOG_FILE_DIR
55+
Resource[] resources = resolver.getResources("file:" + TracerLogRootDaemon.LOG_FILE_DIR
5656
+ File.separator + ROLLING_TEST_FILE_NAME
5757
+ "*");
5858
Assert.assertTrue("文件的数量不正确,以 " + ROLLING_TEST_FILE_NAME + " 为开头的文件数量应该是 2 个",

tracer-core/src/test/java/com/alipay/common/tracer/core/appender/info/StaticInfoLogTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.alipay.common.tracer.core.appender.info;
1818

1919
import com.alipay.common.tracer.core.appender.TraceAppender;
20-
import com.alipay.common.tracer.core.appender.TracerLogRootDeamon;
20+
import com.alipay.common.tracer.core.appender.TracerLogRootDaemon;
2121
import com.alipay.common.tracer.core.appender.file.TimedRollingFileAppender;
2222
import com.alipay.common.tracer.core.base.AbstractTestBase;
2323
import com.alipay.common.tracer.core.utils.TracerUtils;
@@ -45,7 +45,7 @@ public class StaticInfoLogTest extends AbstractTestBase {
4545

4646
@Before
4747
public void setup() {
48-
File logDirectoryStaticInfoFile = new File(TracerLogRootDeamon.LOG_FILE_DIR
48+
File logDirectoryStaticInfoFile = new File(TracerLogRootDaemon.LOG_FILE_DIR
4949
+ File.separator + "static-info.log");
5050
if (!logDirectoryStaticInfoFile.exists()) {
5151
return;
@@ -55,8 +55,8 @@ public void setup() {
5555
} catch (IOException e) {
5656
throw new RuntimeException(e);
5757
}
58-
assertTrue("LogRoot : " + TracerLogRootDeamon.LOG_FILE_DIR,
59-
TracerLogRootDeamon.LOG_FILE_DIR.contains("tracelog"));
58+
assertTrue("LogRoot : " + TracerLogRootDaemon.LOG_FILE_DIR,
59+
TracerLogRootDaemon.LOG_FILE_DIR.contains("tracelog"));
6060
}
6161

6262
@Test

tracer-core/src/test/java/com/alipay/common/tracer/core/appender/manager/ConcurrentConsumerCorrectTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.alipay.common.tracer.core.appender.manager;
1818

1919
import com.alipay.common.tracer.core.appender.TraceAppender;
20-
import com.alipay.common.tracer.core.appender.TracerLogRootDeamon;
20+
import com.alipay.common.tracer.core.appender.TracerLogRootDaemon;
2121
import com.alipay.common.tracer.core.appender.file.LoadTestAwareAppender;
2222
import com.alipay.common.tracer.core.configuration.SofaTracerConfiguration;
2323
import com.alipay.common.tracer.core.span.SofaTracerSpan;
@@ -41,7 +41,7 @@
4141
*/
4242
public class ConcurrentConsumerCorrectTest {
4343

44-
static final String fileNameRoot = TracerLogRootDeamon.LOG_FILE_DIR + File.separator;
44+
static final String fileNameRoot = TracerLogRootDaemon.LOG_FILE_DIR + File.separator;
4545
static final String fileName1 = "log1.log";
4646
static final String fileName2 = "log2.log";
4747
static final String fileName3 = "log3.log";

tracer-core/src/test/java/com/alipay/common/tracer/core/appender/manager/ConcurrentDiscardTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.alipay.common.tracer.core.appender.manager;
1818

1919
import com.alipay.common.tracer.core.appender.TraceAppender;
20-
import com.alipay.common.tracer.core.appender.TracerLogRootDeamon;
20+
import com.alipay.common.tracer.core.appender.TracerLogRootDaemon;
2121
import com.alipay.common.tracer.core.appender.file.LoadTestAwareAppender;
2222
import com.alipay.common.tracer.core.appender.self.SelfLog;
2323
import com.alipay.common.tracer.core.appender.self.SynchronizingSelfLog;
@@ -43,7 +43,7 @@
4343
* @version $Id: ConcurrentDiscardTest.java, v 0.1 2017年10月23日 下午8:22 liangen Exp $
4444
*/
4545
public class ConcurrentDiscardTest {
46-
static final String fileNameRoot = TracerLogRootDeamon.LOG_FILE_DIR + File.separator;
46+
static final String fileNameRoot = TracerLogRootDaemon.LOG_FILE_DIR + File.separator;
4747
static final String fileName1 = "log1.log";
4848
static final String fileName2 = "log2.log";
4949
static final String fileName3 = "log3.log";

tracer-core/src/test/java/com/alipay/common/tracer/core/appender/self/SelfLogTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
package com.alipay.common.tracer.core.appender.self;
1818

19-
import com.alipay.common.tracer.core.appender.TracerLogRootDeamon;
19+
import com.alipay.common.tracer.core.appender.TracerLogRootDaemon;
2020
import com.alipay.common.tracer.core.appender.manager.AsyncCommonAppenderManager;
2121
import com.alipay.common.tracer.core.base.AbstractTestBase;
2222
import org.apache.commons.io.FileUtils;
@@ -65,7 +65,7 @@ public void testErrorForLogE() throws Exception {
6565
SelfLog.error("Error info", new RuntimeException("RunTimeException"));
6666
Thread.sleep(4000);
6767

68-
List<String> logs = FileUtils.readLines(new File(TracerLogRootDeamon.LOG_FILE_DIR
68+
List<String> logs = FileUtils.readLines(new File(TracerLogRootDaemon.LOG_FILE_DIR
6969
+ File.separator + SelfLog.SELF_LOG_FILE));
7070
assertTrue(logs.size() > 0);
7171
}
@@ -77,7 +77,7 @@ public void testErrorForLogE() throws Exception {
7777
public void testErrorWithTraceIdForLogE() throws Exception {
7878
SelfLog.errorWithTraceId("error Info ", "traceid");
7979
Thread.sleep(4000);
80-
List<String> logs = FileUtils.readLines(new File(TracerLogRootDeamon.LOG_FILE_DIR
80+
List<String> logs = FileUtils.readLines(new File(TracerLogRootDaemon.LOG_FILE_DIR
8181
+ File.separator + SelfLog.SELF_LOG_FILE));
8282
assertTrue(logs.toString(), logs.size() > 0);
8383
}
@@ -92,7 +92,7 @@ public void testErrorLog() throws Exception {
9292

9393
Thread.sleep(4000);
9494

95-
List<String> logs = FileUtils.readLines(new File(TracerLogRootDeamon.LOG_FILE_DIR
95+
List<String> logs = FileUtils.readLines(new File(TracerLogRootDaemon.LOG_FILE_DIR
9696
+ File.separator + SelfLog.SELF_LOG_FILE));
9797
StringBuilder stringBuilder = new StringBuilder();
9898
for (int i = 0; i < logs.size(); i++) {

tracer-samples/tracer-sample-with-zipkin/README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@
4141

4242
## 启用 SOFATracer 汇报数据到 Zipkin
4343

44-
1. 配置 `com.alipay.sofa.tracer.zipkin.enabled=true` 激活 SOFATracer 数据上报到 [Zipkin](https://zipkin.io/)
45-
2. 配置 Zipkin Server 端的地址 `com.alipay.sofa.tracer.zipkin.baseUrl=http://${ip}:${port}`
44+
配置 Zipkin Server 端的地址 `com.alipay.sofa.tracer.zipkin.baseUrl=http://${ip}:${port}`
4645

47-
配置好上述两个项目后,即激活了远程上报的能力。本示例中已经搭建好的 Zipkin Server 端地址是 `http://zipkin-cloud-3.host.net:9411`
46+
按照上文完成了依赖和 Zipkin Server 的配置后,即激活了远程上报的能力。本示例中已经搭建好的 Zipkin Server 端地址是 `http://zipkin-cloud-3.host.net:9411`
4847

4948
## 运行
5049

tracer-samples/tracer-sample-with-zipkin/src/main/resources/application.properties

-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,5 @@
1919
spring.application.name=SOFATracerReportZipkin
2020
# logging path
2121
logging.path=./logs
22-
# enable zipkin
23-
com.alipay.sofa.tracer.zipkin.enabled=true
2422
# zipkin server url
2523
com.alipay.sofa.tracer.zipkin.baseUrl=http://zipkin-cloud.host.net:9411

tracer-sofa-boot-starter/src/main/java/com/alipay/sofa/tracer/boot/zipkin/configuration/ZipkinSofaTracerAutoConfiguration.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.alipay.sofa.tracer.boot.zipkin.ZipkinSofaTracerSpanRemoteReporter;
2020
import com.alipay.sofa.tracer.boot.zipkin.properties.ZipkinSofaTracerProperties;
2121
import com.alipay.sofa.tracer.boot.zipkin.properties.ZipkinSofaTracerSamplerProperties;
22+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2223
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
2324
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
2425
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -35,7 +36,8 @@
3536
@Configuration
3637
@EnableConfigurationProperties({ ZipkinSofaTracerProperties.class,
3738
ZipkinSofaTracerSamplerProperties.class })
38-
@ConditionalOnProperty(value = "com.alipay.sofa.tracer.zipkin.enabled")
39+
@ConditionalOnProperty(value = "com.alipay.sofa.tracer.zipkin.enabled", matchIfMissing = true)
40+
@ConditionalOnClass({ zipkin.Span.class, zipkin.reporter.AsyncReporter.class })
3941
public class ZipkinSofaTracerAutoConfiguration {
4042

4143
@Bean

tracer-sofa-boot-starter/src/test/resources/application-zipkin.properties

-2
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,3 @@
1717

1818
spring.application.name=zipkin-client
1919
com.alipay.sofa.tracer.springmvc.jsonOutput=false
20-
# enable zipkin
21-
com.alipay.sofa.tracer.zipkin.enabled=true

0 commit comments

Comments
 (0)