@@ -31,6 +31,7 @@ import (
31
31
32
32
clientset "github.com/openebs/lvm-localpv/pkg/generated/clientset/internalclientset"
33
33
informers "github.com/openebs/lvm-localpv/pkg/generated/informer/externalversions"
34
+ "github.com/openebs/lvm-localpv/pkg/version"
34
35
35
36
"github.com/container-storage-interface/spec/lib/go/csi"
36
37
"golang.org/x/net/context"
@@ -45,12 +46,12 @@ import (
45
46
"github.com/openebs/lib-csi/pkg/common/errors"
46
47
schd "github.com/openebs/lib-csi/pkg/scheduler"
47
48
49
+ analytics "github.com/openebs/google-analytics-4/usage"
48
50
lvmapi "github.com/openebs/lvm-localpv/pkg/apis/openebs.io/lvm/v1alpha1"
49
51
"github.com/openebs/lvm-localpv/pkg/builder/snapbuilder"
50
52
"github.com/openebs/lvm-localpv/pkg/builder/volbuilder"
51
53
"github.com/openebs/lvm-localpv/pkg/lvm"
52
54
csipayload "github.com/openebs/lvm-localpv/pkg/response"
53
- analytics "github.com/openebs/lvm-localpv/pkg/usage"
54
55
)
55
56
56
57
// size constants
@@ -59,6 +60,16 @@ const (
59
60
GB = 1000 * 1000 * 1000
60
61
Mi = 1024 * 1024
61
62
Gi = 1024 * 1024 * 1024
63
+
64
+ // Ping event is sent periodically
65
+ Ping string = "lvm-ping"
66
+
67
+ // DefaultCASType Event application name constant for volume event
68
+ DefaultCASType string = "lvm-localpv"
69
+
70
+ // LocalPVReplicaCount is the constant used by usage to represent
71
+ // replication factor in LocalPV
72
+ LocalPVReplicaCount string = "1"
62
73
)
63
74
64
75
// controller is the server implementation
@@ -99,14 +110,13 @@ var SupportedVolumeCapabilityAccessModes = []*csi.VolumeCapability_AccessMode{
99
110
}
100
111
101
112
// sendEventOrIgnore sends anonymous local-pv provision/delete events
102
- func sendEventOrIgnore (pvcName , pvName , capacity , stgType , method string ) {
113
+ func sendEventOrIgnore (pvcName , pvName , capacity , method string ) {
103
114
if lvm .GoogleAnalyticsEnabled == "true" {
104
- analytics .New ().Build ().ApplicationBuilder ().
105
- SetVolumeType (stgType , method ).
106
- SetDocumentTitle (pvName ).
107
- SetCampaignName (pvcName ).
115
+ analytics .New ().CommonBuild (DefaultCASType ).ApplicationBuilder ().
116
+ SetVolumeName (pvName ).
117
+ SetVolumeClaimName (pvcName ).
108
118
SetLabel (analytics .EventLabelCapacity ).
109
- SetReplicaCount (analytics . LocalPVReplicaCount , method ).
119
+ SetReplicaCount (LocalPVReplicaCount , method ).
110
120
SetCategory (method ).
111
121
SetVolumeCapacity (capacity ).Send ()
112
122
}
@@ -232,8 +242,9 @@ func (cs *controller) init() error {
232
242
go pvcInformer .Informer ().Run (stopCh )
233
243
234
244
if lvm .GoogleAnalyticsEnabled == "true" {
235
- analytics .New ().Build ().InstallBuilder (true ).Send ()
236
- go analytics .PingCheck ()
245
+ analytics .RegisterVersionGetter (version .GetVersionDetails )
246
+ analytics .New ().CommonBuild (DefaultCASType ).InstallBuilder (true ).Send ()
247
+ go analytics .PingCheck (DefaultCASType , Ping )
237
248
}
238
249
239
250
if cs .leakProtection , err = csipv .NewLeakProtectionController (kubeClient ,
@@ -367,7 +378,7 @@ func (cs *controller) CreateVolume(
367
378
}
368
379
sendEventOrIgnore (params .PVCName , volName ,
369
380
strconv .FormatInt (int64 (size ), 10 ),
370
- "lvm-localpv" , analytics .VolumeProvision )
381
+ analytics .VolumeProvision )
371
382
372
383
topology := map [string ]string {lvm .LVMTopologyKey : vol .Spec .OwnerNodeID }
373
384
cntx := map [string ]string {lvm .VolGroupKey : vol .Spec .VolGroup , lvm .OpenEBSCasTypeKey : lvm .LVMCasTypeName }
@@ -419,7 +430,7 @@ func (cs *controller) deleteVolume(ctx context.Context, volumeID string) error {
419
430
if err = lvm .WaitForLVMVolumeDestroy (ctx , volumeID ); err != nil {
420
431
return err
421
432
}
422
- sendEventOrIgnore ("" , volumeID , vol .Spec .Capacity , "lvm-localpv" , analytics .VolumeDeprovision )
433
+ sendEventOrIgnore ("" , volumeID , vol .Spec .Capacity , analytics .VolumeDeprovision )
423
434
return nil
424
435
}
425
436
0 commit comments