Skip to content

Commit

Permalink
[ISSUE #585] Fix the wrong StoreHost and GroupName with consume trace…
Browse files Browse the repository at this point in the history
… message (#586)

* Add more trace field

* fix test failure

* Fix go fmt can not pass

Co-authored-by: zhangxu16 <[email protected]>
  • Loading branch information
maixiaohai and zhangxu16 authored Jun 17, 2021
1 parent de657f5 commit 9768869
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions internal/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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:
Expand All @@ -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)
}
}
Expand Down
6 changes: 3 additions & 3 deletions internal/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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() {
Expand Down Expand Up @@ -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"}
Expand Down

0 comments on commit 9768869

Please sign in to comment.