diff --git a/internal/trace.go b/internal/trace.go index e4a8cdd8..a7fee679 100644 --- a/internal/trace.go +++ b/internal/trace.go @@ -122,6 +122,8 @@ func (ctx *TraceContext) marshal2Bean() *TraceTransferBean { buffer.WriteString(bean.OffsetMsgId) buffer.WriteRune(contentSplitter) buffer.WriteString(strconv.FormatBool(ctx.IsSuccess)) + buffer.WriteRune(contentSplitter) + buffer.WriteString(bean.ClientHost) buffer.WriteRune(fieldSplitter) case SubBefore: for _, bean := range ctx.TraceBeans { @@ -145,6 +147,8 @@ func (ctx *TraceContext) marshal2Bean() *TraceTransferBean { buffer.WriteString(strconv.Itoa(bean.RetryTimes)) buffer.WriteRune(contentSplitter) buffer.WriteString(nullWrap(bean.Keys)) + buffer.WriteRune(contentSplitter) + buffer.WriteString(bean.ClientHost) buffer.WriteRune(fieldSplitter) } case SubAfter: @@ -162,6 +166,10 @@ func (ctx *TraceContext) marshal2Bean() *TraceTransferBean { buffer.WriteString(nullWrap(bean.Keys)) buffer.WriteRune(contentSplitter) buffer.WriteString(strconv.Itoa(ctx.ContextCode)) + buffer.WriteRune(contentSplitter) + buffer.WriteString(strconv.FormatInt(ctx.TimeStamp, 10)) + buffer.WriteRune(contentSplitter) + buffer.WriteString(ctx.GroupName) buffer.WriteRune(fieldSplitter) } } diff --git a/internal/trace_test.go b/internal/trace_test.go index 9c66f812..a636b382 100644 --- a/internal/trace_test.go +++ b/internal/trace_test.go @@ -54,7 +54,7 @@ func TestMarshal2Bean(t *testing.T) { }, } bean := traceCtx.marshal2Bean() - assert.Equal(t, "Pub1563780533299DefaultRegionProducerGroupNameTopicTest0A5DE93A833B18B4AAC26F842A2F0000TagAOrderID188210.93.233.58:1091111357200A5DE93A00002A9F000000000042E322true\x02", + assert.Equal(t, "Pub1563780533299DefaultRegionProducerGroupNameTopicTest0A5DE93A833B18B4AAC26F842A2F0000TagAOrderID188210.93.233.58:1091111357200A5DE93A00002A9F000000000042E322true10.93.233.58\x02", bean.transData) assert.Equal(t, []string{"0A5DE93A833B18B4AAC26F842A2F0000", "OrderID1882"}, bean.transKey) @@ -81,7 +81,7 @@ func TestMarshal2Bean(t *testing.T) { bean = traceCtx.marshal2Bean() Convey("transData should equal to expected", func() { - So(bean.transData, ShouldEqual, "SubBefore1563789119096CID_JODIE_10A5DE93A96A818B4AAC26FFAFA7800070A5DE93A973418B4AAC26FFAFA5A00000OrderID1882") + So(bean.transData, ShouldEqual, "SubBefore1563789119096CID_JODIE_10A5DE93A96A818B4AAC26FFAFA7800070A5DE93A973418B4AAC26FFAFA5A00000OrderID188210.93.233.58") }) Convey("transkey should equal to expected", func() { @@ -113,7 +113,7 @@ func TestMarshal2Bean(t *testing.T) { } bean := traceCtx.marshal2Bean() Convey("transData should equal to expected", func() { - So(bean.transData, ShouldEqual, "SubAfter0A5DE93A96A818B4AAC26FFAFA7800070A5DE93A973418B4AAC26FFAFA5A00000trueOrderID18820") + So(bean.transData, ShouldEqual, "SubAfter0A5DE93A96A818B4AAC26FFAFA7800070A5DE93A973418B4AAC26FFAFA5A00000trueOrderID188201563789119096CID_JODIE_1") }) Convey("transkey should equal to expected", func() { expectedKey := []string{"0A5DE93A973418B4AAC26FFAFA5A0000", "OrderID1882"}