@@ -131,18 +131,16 @@ func newICMPProxy(listenIP netip.Addr, zone string, logger *zerolog.Logger, idle
131131}
132132
133133func (ip * icmpProxy ) Request (ctx context.Context , pk * packet.ICMP , responder * packetResponder ) error {
134- ctx , span := responder .requestSpan (ctx , pk )
134+ _ , span := responder .requestSpan (ctx , pk )
135135 defer responder .exportSpan ()
136136
137137 originalEcho , err := getICMPEcho (pk .Message )
138138 if err != nil {
139139 tracing .EndWithErrorStatus (span , err )
140140 return err
141141 }
142- span .SetAttributes (
143- attribute .Int ("originalEchoID" , originalEcho .ID ),
144- attribute .Int ("seq" , originalEcho .Seq ),
145- )
142+ observeICMPRequest (ip .logger , span , pk .Src .String (), pk .Dst .String (), originalEcho .ID , originalEcho .Seq )
143+
146144 echoIDTrackerKey := flow3Tuple {
147145 srcIP : pk .Src ,
148146 dstIP : pk .Dst ,
@@ -189,6 +187,7 @@ func (ip *icmpProxy) Request(ctx context.Context, pk *packet.ICMP, responder *pa
189187 tracing .EndWithErrorStatus (span , err )
190188 return err
191189 }
190+
192191 err = icmpFlow .sendToDst (pk .Dst , pk .Message )
193192 if err != nil {
194193 tracing .EndWithErrorStatus (span , err )
@@ -269,15 +268,12 @@ func (ip *icmpProxy) sendReply(ctx context.Context, reply *echoReply) error {
269268 _ , span := icmpFlow .responder .replySpan (ctx , ip .logger )
270269 defer icmpFlow .responder .exportSpan ()
271270
272- span .SetAttributes (
273- attribute .String ("dst" , reply .from .String ()),
274- attribute .Int ("echoID" , reply .echo .ID ),
275- attribute .Int ("seq" , reply .echo .Seq ),
276- attribute .Int ("originalEchoID" , icmpFlow .originalEchoID ),
277- )
278271 if err := icmpFlow .returnToSrc (reply ); err != nil {
279272 tracing .EndWithErrorStatus (span , err )
273+ return err
280274 }
275+ observeICMPReply (ip .logger , span , reply .from .String (), reply .echo .ID , reply .echo .Seq )
276+ span .SetAttributes (attribute .Int ("originalEchoID" , icmpFlow .originalEchoID ))
281277 tracing .End (span )
282278 return nil
283279}
0 commit comments