@@ -25,6 +25,7 @@ import (
25
25
"google.golang.org/grpc/codes"
26
26
"k8s.io/component-base/metrics"
27
27
"k8s.io/klog/v2"
28
+ "k8s.io/mount-utils"
28
29
"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common"
29
30
)
30
31
53
54
StabilityLevel : metrics .ALPHA ,
54
55
},
55
56
[]string {"driver_name" , "method_name" , "grpc_status_code" , "disk_type" , "enable_confidential_storage" , "enable_storage_pools" })
57
+
58
+ mountErrorMetric = metrics .NewCounterVec (& metrics.CounterOpts {
59
+ Subsystem : "node" ,
60
+ Name : "mount_errors" ,
61
+ Help : "Node server file system mounting errors" ,
62
+ StabilityLevel : metrics .ALPHA ,
63
+ },
64
+ []string {"error_type" },
65
+ )
56
66
)
57
67
58
68
type MetricsManager struct {
@@ -78,6 +88,10 @@ func (mm *MetricsManager) RegisterPDCSIMetric() {
78
88
mm .registry .MustRegister (pdcsiOperationErrorsMetric )
79
89
}
80
90
91
+ func (mm * MetricsManager ) RegisterMountMetric () {
92
+ mm .registry .MustRegister (mountErrorMetric )
93
+ }
94
+
81
95
func (mm * MetricsManager ) recordComponentVersionMetric () error {
82
96
v := getEnvVar (envGKEPDCSIVersion )
83
97
if v == "" {
@@ -101,6 +115,19 @@ func (mm *MetricsManager) RecordOperationErrorMetrics(
101
115
klog .Infof ("Recorded PDCSI operation error code: %q" , errCode )
102
116
}
103
117
118
+ func (mm * MetricsManager ) RecordMountErrorMetric (err error ) {
119
+ mntErr := & mount.MountError {}
120
+ if errors .As (err , mntErr ) {
121
+ mountErrorMetric .WithLabelValues (string (mntErr .Type )).Inc ()
122
+ }
123
+
124
+ klog .Infof ("Recorded mount error type: %q" , mntErr .Type )
125
+ }
126
+
127
+ func (mm * MetricsManager ) EmmitProcessStartTime () error {
128
+ return metrics .RegisterProcessStartTime (mm .registry .Register )
129
+ }
130
+
104
131
func (mm * MetricsManager ) EmitGKEComponentVersion () error {
105
132
mm .registerComponentVersionMetric ()
106
133
if err := mm .recordComponentVersionMetric (); err != nil {
0 commit comments