@@ -26,7 +26,8 @@ import (
26
26
"github.com/deepflowio/deepflow/server/libs/utils"
27
27
)
28
28
29
- const TRACE_TREE_VERSION = 0x12
29
+ const TRACE_TREE_VERSION_0X12 = 0x12 // before 20240827
30
+ const TRACE_TREE_VERSION = 0x13
30
31
31
32
func HashSearchIndex (key string ) uint64 {
32
33
return utils .DJBHash (17 , key )
@@ -75,9 +76,9 @@ type TreeNode struct {
75
76
NodeInfo NodeInfo
76
77
77
78
ChildIndices []int32 // helps with calculations, no need to write to Clickhouse
78
- PseudoLink uint8 // helps with calculations, no need to write to Clickhouse
79
- Level uint8 // helps with calculations, no need to write to Clickhouse
80
- UID string // helps with calculations, no need to write to Clickhouse
79
+ PseudoLink uint8
80
+ Level uint8 // helps with calculations, no need to write to Clickhouse
81
+ UID string // helps with calculations, no need to write to Clickhouse
81
82
82
83
Topic string
83
84
@@ -171,6 +172,7 @@ func (t *TraceTree) Encode() {
171
172
encoder .WriteIPv6 (nodeInfo .IP6 )
172
173
}
173
174
175
+ encoder .WriteU8 (node .PseudoLink )
174
176
encoder .WriteString255 (node .Topic )
175
177
encoder .WriteVarintU64 (node .ResponseDurationSum )
176
178
encoder .WriteVarintU32 (node .ResponseTotal )
@@ -181,7 +183,7 @@ func (t *TraceTree) Encode() {
181
183
182
184
func (t * TraceTree ) Decode (decoder * codec.SimpleDecoder ) error {
183
185
version := decoder .ReadU8 ()
184
- if version != TRACE_TREE_VERSION {
186
+ if version != TRACE_TREE_VERSION && version != TRACE_TREE_VERSION_0X12 {
185
187
return fmt .Errorf ("trace tree data version is %d expect version is %d" , version , TRACE_TREE_VERSION )
186
188
}
187
189
treeNodeCount := int (decoder .ReadU16 ())
@@ -230,7 +232,11 @@ func (t *TraceTree) Decode(decoder *codec.SimpleDecoder) error {
230
232
}
231
233
n .ChildIndices = n .ChildIndices [:0 ]
232
234
n .Level = 0
233
- n .PseudoLink = 0
235
+ if version == TRACE_TREE_VERSION_0X12 {
236
+ n .PseudoLink = 0
237
+ } else {
238
+ n .PseudoLink = decoder .ReadU8 ()
239
+ }
234
240
n .UID = ""
235
241
n .Topic = decoder .ReadString255 ()
236
242
n .ResponseDurationSum = decoder .ReadVarintU64 ()
0 commit comments