Skip to content

Commit fa3c5ea

Browse files
TomatoMrrvql
authored andcommitted
[Agent] fix otel data's ip address needs to be saved as 0
1 parent 7eb3c97 commit fa3c5ea

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

agent/src/collector/collector.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,8 @@ impl Stash {
546546
Ipv4Addr::UNSPECIFIED.into()
547547
}
548548
} else if ep == FLOW_METRICS_PEER_SRC {
549-
if flow.flow_metrics_peers[0].l3_epc_id > 0 {
549+
if flow.flow_metrics_peers[0].l3_epc_id > 0 || flow.signal_source == SignalSource::OTel
550+
{
550551
flow.flow_metrics_peers[0].nat_real_ip
551552
} else {
552553
if is_ipv6 {
@@ -556,7 +557,8 @@ impl Stash {
556557
}
557558
}
558559
} else {
559-
if flow.flow_metrics_peers[1].l3_epc_id > 0 {
560+
if flow.flow_metrics_peers[1].l3_epc_id > 0 || flow.signal_source == SignalSource::OTel
561+
{
560562
flow.flow_metrics_peers[1].nat_real_ip
561563
} else {
562564
if is_ipv6 {
@@ -676,17 +678,22 @@ impl Stash {
676678
}
677679
} else {
678680
// After enabling the storage of inactive IP addresses,
679-
// the Internet IP address also needs to be saved as 0
681+
// the Internet IP address also needs to be saved as 0,
682+
// except for otel data
680683
// =======================================
681-
// 开启存储非活跃IP后,Internet IP也需要存0
682-
if flow.flow_metrics_peers[0].l3_epc_id <= 0 {
684+
// 开启存储非活跃IP后,Internet IP也需要存0, otel数据除外
685+
if flow.flow_metrics_peers[0].l3_epc_id <= 0
686+
&& flow.signal_source != SignalSource::OTel
687+
{
683688
src_ip = if is_ipv6 {
684689
Ipv6Addr::UNSPECIFIED.into()
685690
} else {
686691
Ipv4Addr::UNSPECIFIED.into()
687692
};
688693
}
689-
if flow.flow_metrics_peers[1].l3_epc_id <= 0 {
694+
if flow.flow_metrics_peers[1].l3_epc_id <= 0
695+
&& flow.signal_source != SignalSource::OTel
696+
{
690697
dst_ip = if is_ipv6 {
691698
Ipv6Addr::UNSPECIFIED.into()
692699
} else {

0 commit comments

Comments
 (0)