From 2cac86626b12fd92e47e9fa12a25ca891214e82a Mon Sep 17 00:00:00 2001 From: StyleTang Date: Sat, 28 Aug 2021 00:04:55 +0800 Subject: [PATCH] [ISSUE #3136] TraceDataEncoder add SubAfter trace bean timestamp (#3137) * [ISSUE #3136] TraceDataEncoder add SubAfter trace bean timestamp * add SubAfter TraceBean TimeStamp and GroupName back --- .../org/apache/rocketmq/client/trace/TraceDataEncoder.java | 5 +++-- .../apache/rocketmq/client/trace/TraceDataEncoderTest.java | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/src/main/java/org/apache/rocketmq/client/trace/TraceDataEncoder.java b/client/src/main/java/org/apache/rocketmq/client/trace/TraceDataEncoder.java index 10aa2413..b4a49a05 100644 --- a/client/src/main/java/org/apache/rocketmq/client/trace/TraceDataEncoder.java +++ b/client/src/main/java/org/apache/rocketmq/client/trace/TraceDataEncoder.java @@ -188,8 +188,9 @@ public class TraceDataEncoder { .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.CONTENT_SPLITOR) + .append(ctx.getGroupName()).append(TraceConstants.FIELD_SPLITOR); } } break; diff --git a/client/src/test/java/org/apache/rocketmq/client/trace/TraceDataEncoderTest.java b/client/src/test/java/org/apache/rocketmq/client/trace/TraceDataEncoderTest.java index e268dff3..03381d01 100644 --- a/client/src/test/java/org/apache/rocketmq/client/trace/TraceDataEncoderTest.java +++ b/client/src/test/java/org/apache/rocketmq/client/trace/TraceDataEncoderTest.java @@ -189,6 +189,8 @@ public class TraceDataEncoderTest { subAfterContext.setRequestId("3455848576927"); subAfterContext.setCostTime(20); subAfterContext.setSuccess(true); + subAfterContext.setTimeStamp(1625883640000L); + subAfterContext.setGroupName("GroupName-test"); subAfterContext.setContextCode(98623046); TraceBean bean = new TraceBean(); bean.setMsgId("AC1415116D1418B4AAC217FE1B4E0000"); @@ -200,7 +202,7 @@ public class TraceDataEncoderTest { String transData = traceTransferBean.getTransData(); Assert.assertNotNull(transData); String[] items = transData.split(String.valueOf(TraceConstants.CONTENT_SPLITOR)); - Assert.assertEquals(7, items.length); + Assert.assertEquals(9, items.length); } -- GitLab