Skip to content

Commit

Permalink
[ISSUE #3136] TraceDataEncoder add SubAfter trace bean timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleTang committed Jul 10, 2021
1 parent 589e87c commit 0933774
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ public static List<TraceContext> decoderFromTraceDataString(String traceData) {
subAfterContext.setContextCode(Integer.parseInt(line[6]));
}
// compatible with the old version
if (line.length >= 9) {
if (line.length >= 8) {
subAfterContext.setTimeStamp(Long.parseLong(line[7]));
subAfterContext.setGroupName(line[8]);
}
resList.add(subAfterContext);
} else if (line[0].equals(TraceType.EndTransaction.name())) {
Expand Down Expand Up @@ -188,7 +187,8 @@ public static TraceTransferBean encoderFromContextBean(TraceContext ctx) {
.append(ctx.getCostTime()).append(TraceConstants.CONTENT_SPLITOR)//
.append(ctx.isSuccess()).append(TraceConstants.CONTENT_SPLITOR)//
.append(bean.getKeys()).append(TraceConstants.CONTENT_SPLITOR)//
.append(ctx.getContextCode()).append(TraceConstants.FIELD_SPLITOR);
.append(ctx.getContextCode()).append(TraceConstants.CONTENT_SPLITOR)
.append(ctx.getTimeStamp()).append(TraceConstants.FIELD_SPLITOR);

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public void testSubAfterTraceDataFormatTest() {
subAfterContext.setRequestId("3455848576927");
subAfterContext.setCostTime(20);
subAfterContext.setSuccess(true);
subAfterContext.setTimeStamp(1625883640000L);
subAfterContext.setContextCode(98623046);
TraceBean bean = new TraceBean();
bean.setMsgId("AC1415116D1418B4AAC217FE1B4E0000");
Expand All @@ -200,7 +201,7 @@ public void testSubAfterTraceDataFormatTest() {
String transData = traceTransferBean.getTransData();
Assert.assertNotNull(transData);
String[] items = transData.split(String.valueOf(TraceConstants.CONTENT_SPLITOR));
Assert.assertEquals(7, items.length);
Assert.assertEquals(8, items.length);

}

Expand Down

0 comments on commit 0933774

Please sign in to comment.