diff --git a/internal/fs/wrappers/monitoring.go b/internal/fs/wrappers/monitoring.go index d09d22f62b..f5ea333145 100644 --- a/internal/fs/wrappers/monitoring.go +++ b/internal/fs/wrappers/monitoring.go @@ -63,7 +63,7 @@ func init() { Measure: opsErrorCount, Description: "The cumulative number of errors generated by file system operations", Aggregation: view.Sum(), - TagKeys: []tag.Key{tags.FSOp, tags.FSError, tags.FSErrCategory}, + TagKeys: []tag.Key{tags.FSOp, tags.FSErrCategory}, }, &view.View{ Name: "fs/ops_latency", @@ -76,24 +76,17 @@ func init() { } } -// errStrAndCategory maps an error to an error string and an error category. -// Uncommon errors are bucketed into categories to reduce the cardinality of the -// error so that the metric is not rejected by Cloud Monarch. -func errStrAndCategory(err error) (str string, category string) { +// categorize maps an error to an error-category. +// This helps reduce the cardinality of the labels to less than 30. +// This lower number of errors allows the various errors to get piped to Cloud metrics without getting dropped. +func categorize(err error) string { if err == nil { - return "", "" + return "" } var errno syscall.Errno if !errors.As(err, &errno) { errno = DefaultFSError } - return errno.Error(), errCategory(errno) -} - -// errCategory maps an error to an error-category. -// This helps reduce the cardinality of the labels to less than 30. -// This lower number of errors allows the various errors to get piped to Cloud metrics without getting dropped. -func errCategory(errno syscall.Errno) string { switch errno { case syscall.ELNRNG, syscall.ENODEV, @@ -262,7 +255,6 @@ func errCategory(errno syscall.Errno) string { // Records file system operation count, failed operation count and the operation latency. func recordOp(ctx context.Context, method string, start time.Time, fsErr error) { - // Recording opCount. if err := stats.RecordWithTags( ctx, @@ -277,12 +269,11 @@ func recordOp(ctx context.Context, method string, start time.Time, fsErr error) // Recording opErrorCount. if fsErr != nil { - errStr, errCategory := errStrAndCategory(fsErr) + errCategory := categorize(fsErr) if err := stats.RecordWithTags( ctx, []tag.Mutator{ tag.Upsert(tags.FSOp, method), - tag.Upsert(tags.FSError, errStr), tag.Upsert(tags.FSErrCategory, errCategory), }, opsErrorCount.M(1), diff --git a/internal/fs/wrappers/monitoring_test.go b/internal/fs/wrappers/monitoring_test.go index 0f5738c902..ab67d2a407 100644 --- a/internal/fs/wrappers/monitoring_test.go +++ b/internal/fs/wrappers/monitoring_test.go @@ -33,82 +33,66 @@ func TestFsErrStrAndCategory(t *testing.T) { t.Parallel() tests := []struct { fsErr error - expectedStr string expectedCategory string }{ { fsErr: fmt.Errorf("some random error"), - expectedStr: "input/output error", expectedCategory: "input/output error", }, { fsErr: syscall.ENOTEMPTY, - expectedStr: "directory not empty", expectedCategory: "directory not empty", }, { fsErr: syscall.EEXIST, - expectedStr: "file exists", expectedCategory: "file exists", }, { fsErr: syscall.EINVAL, - expectedStr: "invalid argument", expectedCategory: "invalid argument", }, { fsErr: syscall.EINTR, - expectedStr: "interrupted system call", expectedCategory: "interrupt errors", }, { fsErr: syscall.ENOSYS, - expectedStr: "function not implemented", expectedCategory: "function not implemented", }, { fsErr: syscall.ENOSPC, - expectedStr: "no space left on device", expectedCategory: "process/resource management errors", }, { fsErr: syscall.E2BIG, - expectedStr: "argument list too long", expectedCategory: "invalid operation", }, { fsErr: syscall.EHOSTDOWN, - expectedStr: "host is down", expectedCategory: "network errors", }, { fsErr: syscall.ENODATA, - expectedStr: "no data available", expectedCategory: "miscellaneous errors", }, { fsErr: syscall.ENODEV, - expectedStr: "no such device", expectedCategory: "device errors", }, { fsErr: syscall.EISDIR, - expectedStr: "is a directory", expectedCategory: "file/directory errors", }, { fsErr: syscall.ENOSYS, - expectedStr: "function not implemented", expectedCategory: "function not implemented", }, { fsErr: syscall.ENFILE, - expectedStr: "too many open files in system", expectedCategory: "too many open files", }, { fsErr: syscall.EPERM, - expectedStr: "operation not permitted", expectedCategory: "permission errors", }, } @@ -117,10 +101,7 @@ func TestFsErrStrAndCategory(t *testing.T) { t.Run(fmt.Sprintf("fsErrStrAndCategor_case_%d", idx), func(t *testing.T) { t.Parallel() - actualErrStr, actualErrGrp := errStrAndCategory(tc.fsErr) - - assert.Equal(t, tc.expectedStr, actualErrStr) - assert.Equal(t, tc.expectedCategory, actualErrGrp) + assert.Equal(t, tc.expectedCategory, categorize(tc.fsErr)) }) } } diff --git a/internal/monitor/tags/tags.go b/internal/monitor/tags/tags.go index 915337beaa..77592afa6b 100644 --- a/internal/monitor/tags/tags.go +++ b/internal/monitor/tags/tags.go @@ -29,9 +29,6 @@ var ( // FSOp annotates the file system op processed. FSOp = tag.MustNewKey("fs_op") - // FSError annotates the file system failed operations with the error type - FSError = tag.MustNewKey("fs_error") - // FSErrCategory reduces the cardinality of FSError by grouping errors together. FSErrCategory = tag.MustNewKey("fs_error_category")