Skip to content

Commit 0c7f7ae

Browse files
taloriclzf575
authored andcommitted
fix: add more conflict validation for tracing
1 parent 0ee9100 commit 0c7f7ae

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

app/app/application/l7_flow_tracing.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3245,6 +3245,10 @@ def _connect_process_and_networks(
32453245
ps_index = ps_parent.get_flow_index()
32463246
ps_span_id = ps_parent.get_span_id()
32473247
ps_response_duration = ps_parent.get_response_duration()
3248+
# 特殊场景,如果叶子是一个 c-p,且已经有一个 child 时
3249+
# 由于这个场景底下接一定是 net_child,而一个 c-p 只可能启动一个网络请求,因此这里规避下矛盾
3250+
if ps_parent.tap_side.startswith("c") and ps_parent.children_count > 0:
3251+
continue
32483252
for _index, related_types in related_flow_index_map.get(ps_index,
32493253
{}).items():
32503254
if related_types & L7_FLOW_RELATIONSHIP_SPAN_ID != L7_FLOW_RELATIONSHIP_SPAN_ID:
@@ -3282,6 +3286,10 @@ def _connect_process_and_networks(
32823286
net_index = net_parent.get_flow_index()
32833287
net_span_id = net_parent.get_span_id()
32843288
net_response_duration = net_parent.get_response_duration()
3289+
# 对称校验,一个 s 网卡下只能有一个接收侧 s-p
3290+
if net_parent.tap_side.startswith(
3291+
"s") and net_parent.children_count > 0:
3292+
continue
32853293
for _index, related_types in related_flow_index_map.get(net_index,
32863294
{}).items():
32873295
if related_types & L7_FLOW_RELATIONSHIP_SPAN_ID != L7_FLOW_RELATIONSHIP_SPAN_ID:
@@ -3328,6 +3336,7 @@ def _connect_process_and_networks(
33283336
ps_parent_index = ps_parent.get_flow_index()
33293337
ps_parent_span_id = ps_parent.get_span_id()
33303338
ps_parent_response_duartion = ps_parent.get_response_duration()
3339+
# 没有校验,因为 c-p 下可能接多个 s-p,s-p 下可能有多个 c-p
33313340
for _index, related_types in related_flow_index_map.get(
33323341
ps_parent_index, {}).items():
33333342
if related_types & L7_FLOW_RELATIONSHIP_SPAN_ID != L7_FLOW_RELATIONSHIP_SPAN_ID:
@@ -3582,6 +3591,7 @@ def _connect_process_and_networks(
35823591

35833592
# 7. 通过 trace_id 关联:叶子 span(客户端侧,无子节点)→ 根 span(服务端侧,无父节点)
35843593
# 条件:trace_id 有交集,tcp_seq 不同,叶子时延 >= 根时延
3594+
# XXX: 此场景仅供临时使用,真正解决方案为使用 span_id 串联二者
35853595
if 'net_span_c_to_s_via_trace_id' in config.span_set_connection_strategies:
35863596
for net_parent in network_leafs:
35873597
if net_parent.children_count > 0:

0 commit comments

Comments
 (0)