Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions cni/network/plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,16 @@ func main() {
}

executionTimeMs := time.Since(startTime).Milliseconds()
cnimetric.Metric = aitelemetry.Metric{
Name: telemetry.CNIExecutimeMetricStr,
Value: float64(executionTimeMs),
CustomDimensions: make(map[string]string),

if cniReport.ErrorMessage != "" || cniReport.EventMessage != "" {
cnimetric.Metric = aitelemetry.Metric{
Name: telemetry.CNIExecutimeMetricStr,
Value: float64(executionTimeMs),
CustomDimensions: make(map[string]string),
}
network.SetCustomDimensions(&cnimetric, nil, err)
telemetry.SendCNIMetric(&cnimetric, tb)
}
network.SetCustomDimensions(&cnimetric, nil, err)
telemetry.SendCNIMetric(&cnimetric, tb)

if err != nil {
reportPluginError(reportManager, tb, err)
Expand All @@ -259,10 +262,11 @@ func main() {
reflect.ValueOf(reportManager.Report).Elem().FieldByName("CniSucceeded").SetBool(true)
reflect.ValueOf(reportManager.Report).Elem().FieldByName("OperationDuration").SetInt(executionTimeMs)

if err = reportManager.SendReport(tb); err != nil {
log.Errorf("SendReport failed due to %v", err)
} else {
log.Printf("Sending report succeeded")
if cniReport.ErrorMessage != "" || cniReport.EventMessage != "" {
if err = reportManager.SendReport(tb); err != nil {
log.Errorf("SendReport failed due to %v", err)
} else {
log.Printf("Sending report succeeded")
}
}

}
6 changes: 4 additions & 2 deletions telemetry/aiwrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ func SendAITelemetry(cnireport CNIReport) {
var msg string
if cnireport.ErrorMessage != "" {
msg = cnireport.ErrorMessage
} else {
} else if cnireport.EventMessage != "" {
msg = cnireport.EventMessage
} else {
return
}

report := aitelemetry.Report{
Message: "CNI:" + msg,
Message: msg,
Context: cnireport.ContainerName,
CustomDimensions: make(map[string]string),
}
Expand Down