From b00a09e59945e9c2c4889ae79c9b71f017fba1f4 Mon Sep 17 00:00:00 2001 From: Paul Johnston Date: Wed, 22 Apr 2020 14:29:51 -0700 Subject: [PATCH 1/6] Added else if to catch empty messages --- telemetry/aiwrapper.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/telemetry/aiwrapper.go b/telemetry/aiwrapper.go index 527af04922..2e6dd1e60d 100644 --- a/telemetry/aiwrapper.go +++ b/telemetry/aiwrapper.go @@ -47,8 +47,10 @@ 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{ From 30c70c7bfad43c8017695f10afd667470c0bcb92 Mon Sep 17 00:00:00 2001 From: Paul Johnston Date: Thu, 23 Apr 2020 11:31:52 -0700 Subject: [PATCH 2/6] Stopped sending empty messages to AI telemetry for CNI --- cni/network/plugin/main.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cni/network/plugin/main.go b/cni/network/plugin/main.go index f8eed1e7ae..d4ce99bcd7 100644 --- a/cni/network/plugin/main.go +++ b/cni/network/plugin/main.go @@ -259,10 +259,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") + } } - } From 1d44cafe538f9ce60af3bf79b7aaae7a79318cd9 Mon Sep 17 00:00:00 2001 From: Paul Johnston Date: Wed, 29 Apr 2020 13:32:27 -0700 Subject: [PATCH 3/6] Removing cni prefix from log messages --- go.sum | 1 + telemetry/aiwrapper.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/go.sum b/go.sum index 615e0d3786..d5213c4cd6 100644 --- a/go.sum +++ b/go.sum @@ -49,6 +49,7 @@ github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkg github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/evanphx/json-patch v4.2.0+incompatible h1:fUDGZCv/7iAN7u0puUVhvKCcsR6vRfwrJatElLBEf0I= github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= diff --git a/telemetry/aiwrapper.go b/telemetry/aiwrapper.go index 2e6dd1e60d..eeb6c11529 100644 --- a/telemetry/aiwrapper.go +++ b/telemetry/aiwrapper.go @@ -54,7 +54,7 @@ func SendAITelemetry(cnireport CNIReport) { } report := aitelemetry.Report{ - Message: "CNI:" + msg, + Message: msg, Context: cnireport.ContainerName, CustomDimensions: make(map[string]string), } From 8ca2543c795836ed682582537d199d7e1e5634ad Mon Sep 17 00:00:00 2001 From: Paul Johnston Date: Wed, 29 Apr 2020 14:09:17 -0700 Subject: [PATCH 4/6] Reverting go.sum change back to what it was before --- go.sum | 1 - 1 file changed, 1 deletion(-) diff --git a/go.sum b/go.sum index d5213c4cd6..615e0d3786 100644 --- a/go.sum +++ b/go.sum @@ -49,7 +49,6 @@ github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkg github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/evanphx/json-patch v4.2.0+incompatible h1:fUDGZCv/7iAN7u0puUVhvKCcsR6vRfwrJatElLBEf0I= github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= From 0dcdc44141208a1fb627ade1eb99362ca85e2592 Mon Sep 17 00:00:00 2001 From: Paul Johnston Date: Wed, 29 Apr 2020 15:15:51 -0700 Subject: [PATCH 5/6] Adding check for empty messages before sending metric --- cni/network/plugin/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cni/network/plugin/main.go b/cni/network/plugin/main.go index d4ce99bcd7..94d9b1fe86 100644 --- a/cni/network/plugin/main.go +++ b/cni/network/plugin/main.go @@ -248,7 +248,9 @@ func main() { CustomDimensions: make(map[string]string), } network.SetCustomDimensions(&cnimetric, nil, err) - telemetry.SendCNIMetric(&cnimetric, tb) + if cniReport.ErrorMessage != "" || cniReport.EventMessage != "" { + telemetry.SendCNIMetric(&cnimetric, tb) + } if err != nil { reportPluginError(reportManager, tb, err) From e1326b7cc7ac67712dd98734061720834a20dbd1 Mon Sep 17 00:00:00 2001 From: Paul Johnston Date: Wed, 29 Apr 2020 16:52:37 -0700 Subject: [PATCH 6/6] Moving empty message check before cnimetric initialization --- cni/network/plugin/main.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cni/network/plugin/main.go b/cni/network/plugin/main.go index 94d9b1fe86..ab668c5db4 100644 --- a/cni/network/plugin/main.go +++ b/cni/network/plugin/main.go @@ -242,13 +242,14 @@ func main() { } executionTimeMs := time.Since(startTime).Milliseconds() - cnimetric.Metric = aitelemetry.Metric{ - Name: telemetry.CNIExecutimeMetricStr, - Value: float64(executionTimeMs), - CustomDimensions: make(map[string]string), - } - network.SetCustomDimensions(&cnimetric, nil, err) + 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) }