@@ -19,11 +19,11 @@ package usage
1919import (
2020 "strconv"
2121
22- k8sapi "github.com/openebs/lib-csi/pkg/client/k8s"
2322 "k8s.io/klog/v2"
2423
2524 ga4Client "github.com/openebs/google-analytics-4/pkg/client"
2625 ga4Event "github.com/openebs/google-analytics-4/pkg/event"
26+ k8sapi "github.com/openebs/lib-csi/pkg/client/k8s"
2727)
2828
2929// Usage struct represents all information about a usage metric sent to
@@ -67,44 +67,22 @@ func (u *Usage) SetCategory(c string) *Usage {
6767 return u
6868}
6969
70- // SetAction sets the action of an event
71- func (u * Usage ) SetAction (a string ) * Usage {
72- u .OpenebsEventBuilder .Action (a )
73- return u
74- }
75-
76- // SetLabel sets the label for an event
77- func (u * Usage ) SetLabel (l string ) * Usage {
78- u .OpenebsEventBuilder .Label (l )
70+ // SetNodeCount sets the node count for a k8s cluster.
71+ func (u * Usage ) SetNodeCount (n string ) * Usage {
72+ u .OpenebsEventBuilder .NodeCount (n )
7973 return u
8074}
8175
82- // SetValue sets the value for an event's label
83- func (u * Usage ) SetValue (v string ) * Usage {
84- u .OpenebsEventBuilder .Value (v )
85- return u
86- }
87-
88- // SetVolumeCapacity sets the storage capacity of the volume for a volume event
76+ // SetVolumeCapacity sets the size of a volume.
8977func (u * Usage ) SetVolumeCapacity (volCapG string ) * Usage {
90- s , _ := toGigaUnits (volCapG )
91- u .SetValue ( strconv . FormatInt ( s , 10 ) )
78+ s , _ := toHumanSize (volCapG )
79+ u .OpenebsEventBuilder . VolumeCapacity ( s )
9280 return u
9381}
9482
95- // SetReplicaCount Wrapper for setting replica count for volume events
96- // NOTE: This doesn't get the replica count in a volume de-provision event.
97- // TODO: Pick the current value of replica-count from the CAS-engine
98- func (u * Usage ) SetReplicaCount (count , method string ) * Usage {
99- if method == VolumeProvision && count == "" {
100- // Case: When volume-provision the replica count isn't specified
101- // it is set to three by default by the m-apiserver
102- u .OpenebsEventBuilder .Action (DefaultReplicaCount )
103- } else {
104- // Catch all case for volume-deprovision event and
105- // volume-provision event with an overridden replica-count
106- u .OpenebsEventBuilder .Action (Replica + count )
107- }
83+ // SetReplicaCount sets the number of replicas for a volume.
84+ func (u * Usage ) SetReplicaCount (replicaCount string ) * Usage {
85+ u .OpenebsEventBuilder .ReplicaCount (replicaCount )
10886 return u
10987}
11088
@@ -149,9 +127,7 @@ func (u *Usage) InstallBuilder(override bool) *Usage {
149127 u .OpenebsEventBuilder .
150128 K8sDefaultNsUid (v .id ).
151129 Category (InstallEvent ).
152- Action (RunningStatus ).
153- Label (EventLabelNode ).
154- Value (strconv .Itoa (clusterSize ))
130+ NodeCount (strconv .Itoa (clusterSize ))
155131
156132 return u
157133}
0 commit comments