@@ -358,6 +358,7 @@ func (plugin *NetPlugin) Add(args *cniSkel.CmdArgs) error {
358358 epInfos []* network.EndpointInfo
359359 )
360360
361+ startTime := time .Now ()
361362 logger .Info ("Processing ADD command" ,
362363 zap .String ("containerId" , args .ContainerID ),
363364 zap .String ("netNS" , args .Netns ),
@@ -438,6 +439,9 @@ func (plugin *NetPlugin) Add(args *cniSkel.CmdArgs) error {
438439 zap .Error (log .NewErrorWithoutStackTrace (err )))
439440
440441 telemetryClient .SendEvent (fmt .Sprintf ("ADD command completed with [ipamAddResult]: %s [epInfos]: %s [error]: %v " , ipamAddResult .PrettyString (), network .FormatSliceOfPointersToString (epInfos ), err ))
442+
443+ operationTimeMs := time .Since (startTime ).Milliseconds ()
444+ telemetryClient .SendMetric (telemetry .CNIAddTimeMetricStr , float64 (operationTimeMs ), make (map [string ]string ))
441445 }()
442446
443447 ipamAddResult = IPAMAddResult {interfaceInfo : make (map [string ]network.InterfaceInfo )}
@@ -960,7 +964,7 @@ func (plugin *NetPlugin) Delete(args *cniSkel.CmdArgs) error {
960964 networkID string
961965 nwInfo network.EndpointInfo
962966 )
963-
967+ startTime := time . Now ()
964968 logger .Info ("Processing DEL command" ,
965969 zap .String ("containerId" , args .ContainerID ),
966970 zap .String ("netNS" , args .Netns ),
@@ -974,6 +978,8 @@ func (plugin *NetPlugin) Delete(args *cniSkel.CmdArgs) error {
974978 zap .String ("pod" , k8sPodName ),
975979 zap .Error (log .NewErrorWithoutStackTrace (err )))
976980 telemetryClient .SendEvent (fmt .Sprintf ("DEL command completed: [podname]: %s [namespace]: %s [error]: %v" , k8sPodName , k8sNamespace , err ))
981+ operationTimeMs := time .Since (startTime ).Milliseconds ()
982+ telemetryClient .SendMetric (telemetry .CNIDelTimeMetricStr , float64 (operationTimeMs ), make (map [string ]string ))
977983 }()
978984
979985 // Parse network configuration from stdin.
0 commit comments