Skip to content

Commit b726291

Browse files
committed
feat: trace tree support store PseudoLink field
1 parent 893384a commit b726291

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

server/libs/tracetree/tracetree.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import (
2626
"github.com/deepflowio/deepflow/server/libs/utils"
2727
)
2828

29-
const TRACE_TREE_VERSION = 0x12
29+
const TRACE_TREE_VERSION_0X12 = 0x12 // before 20240827
30+
const TRACE_TREE_VERSION = 0x13
3031

3132
func HashSearchIndex(key string) uint64 {
3233
return utils.DJBHash(17, key)
@@ -75,9 +76,9 @@ type TreeNode struct {
7576
NodeInfo NodeInfo
7677

7778
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
8182

8283
Topic string
8384

@@ -171,6 +172,7 @@ func (t *TraceTree) Encode() {
171172
encoder.WriteIPv6(nodeInfo.IP6)
172173
}
173174

175+
encoder.WriteU8(node.PseudoLink)
174176
encoder.WriteString255(node.Topic)
175177
encoder.WriteVarintU64(node.ResponseDurationSum)
176178
encoder.WriteVarintU32(node.ResponseTotal)
@@ -181,7 +183,7 @@ func (t *TraceTree) Encode() {
181183

182184
func (t *TraceTree) Decode(decoder *codec.SimpleDecoder) error {
183185
version := decoder.ReadU8()
184-
if version != TRACE_TREE_VERSION {
186+
if version != TRACE_TREE_VERSION && version != TRACE_TREE_VERSION_0X12 {
185187
return fmt.Errorf("trace tree data version is %d expect version is %d", version, TRACE_TREE_VERSION)
186188
}
187189
treeNodeCount := int(decoder.ReadU16())
@@ -230,7 +232,11 @@ func (t *TraceTree) Decode(decoder *codec.SimpleDecoder) error {
230232
}
231233
n.ChildIndices = n.ChildIndices[:0]
232234
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+
}
234240
n.UID = ""
235241
n.Topic = decoder.ReadString255()
236242
n.ResponseDurationSum = decoder.ReadVarintU64()

0 commit comments

Comments
 (0)