Skip to content

Commit 560cf9a

Browse files
authored
feat: refactor cni telemetry (#3149)
* move telemetry to dedicated package and create package variable * send telemetry for ipam config, epinfo, and error on cni add completion * add new telemetry logs for debugging * replace nwcfg subcontext with containerid for correlation * add mutex * address linter issues * add unit tests * set operation id before sending any events for sampling * remove newly added telemetry events we will split this part of the pr into its own pr a telemetry event was added back which was previously removed undo this pr to add those telemetry statements back * refactor plugin main remove reflect remove duplicated telemetry and telemetry buffer remove unused fields in report manager force access to telemetry client fields through methods move telemetry start/connect code closer to start of plugin execution * add unit tests and simplify we use SendError where we would have previously called reportPluginError (no log emitted) we don't set error message in cni report because the error message and event message fields both end up in the Message field in the cni telemetry service * remove duplicate error telemetry * fix comment * remove writing telemetry events to the log file * address feedback * remove stutter * remove unused map (noop) * address feedback * fix condition * align flow with previous telemetry flow tested and none panic: telemetry service running, lock acquired telemetry service not running, lock acquired telemetry service running, lock not acquired telemetry service not running, lock not acquired stateless if telemetry service not running stateless if telemetry service is running * address linter * re-implement add and delete timing metrics
1 parent 6494e4c commit 560cf9a

15 files changed

+327
-303
lines changed

cni/network/common.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,14 @@ import (
44
"encoding/json"
55
"io"
66
"os"
7-
"reflect"
87

98
"github.com/Azure/azure-container-networking/cni"
10-
"github.com/Azure/azure-container-networking/telemetry"
119
"github.com/containernetworking/cni/pkg/skel"
1210
cniTypes "github.com/containernetworking/cni/pkg/types"
1311
"github.com/pkg/errors"
1412
"go.uber.org/zap"
1513
)
1614

17-
// send error report to hostnetagent if CNI encounters any error.
18-
func ReportPluginError(reportManager *telemetry.ReportManager, tb *telemetry.TelemetryBuffer, err error) {
19-
logger.Error("Report plugin error")
20-
reflect.ValueOf(reportManager.Report).Elem().FieldByName("ErrorMessage").SetString(err.Error())
21-
22-
if err := reportManager.SendReport(tb); err != nil {
23-
logger.Error("SendReport failed", zap.Error(err))
24-
}
25-
}
26-
2715
func validateConfig(jsonBytes []byte) error {
2816
var conf struct {
2917
Name string `json:"name"`

0 commit comments

Comments
 (0)