Skip to content

Commit

Permalink
feat(analytics): add heartbeat pinger
Browse files Browse the repository at this point in the history
Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
  • Loading branch information
niladrih committed Jun 24, 2024
1 parent 6735c35 commit b4c621b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/kubernetes-csi/csi-lib-utils v0.9.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.27.7
github.com/openebs/google-analytics-4 v0.1.0
github.com/openebs/google-analytics-4 v0.2.0
github.com/openebs/lib-csi v0.8.2
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.6.0
Expand All @@ -28,7 +28,7 @@ require (

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
github.com/emicklei/go-restful/v3 v3.8.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
Expand Down Expand Up @@ -309,8 +309,8 @@ github.com/onsi/gomega v1.27.3/go.mod h1:5vG284IBtfDAmDyrK+eGyZmUgUlmi+Wngqo557c
github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3q3fQ=
github.com/onsi/gomega v1.27.7 h1:fVih9JD6ogIiHUN6ePK7HJidyEDpWGVB5mzM7cWNXoU=
github.com/onsi/gomega v1.27.7/go.mod h1:1p8OOlwo2iUUDsHnOrjE5UKYJ+e3W8eQ3qSlRahPmr4=
github.com/openebs/google-analytics-4 v0.1.0 h1:6aUDbQoh1ezb+NU/MkapFKffogW4QK3WYt8g2UmENe8=
github.com/openebs/google-analytics-4 v0.1.0/go.mod h1:3DkQfGCo79pZhL76Xtg0/R7LNLMttW6Bm/uP0yiZQHU=
github.com/openebs/google-analytics-4 v0.2.0 h1:zokvnWat73QscmEsU/LH/zCZsTCMz0x6bJ4qUwMHoNE=
github.com/openebs/google-analytics-4 v0.2.0/go.mod h1:lKjvRs6HAYOlOTYjtOUp35iTutoXzRL0hOeVAvLAfZI=
github.com/openebs/lib-csi v0.8.2 h1:HmoiZX3VXFPglwqnRPnRus7K58ixDWBa19OpPZGk2Ws=
github.com/openebs/lib-csi v0.8.2/go.mod h1:4yc0Q1thH+oU80z73zGELfrOw2yeLdLNIRmcrxBxsBc=
github.com/pborman/uuid v0.0.0-20170612153648-e790cca94e6c/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34=
Expand Down
28 changes: 15 additions & 13 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ import (
"time"

k8sapi "github.com/openebs/lib-csi/pkg/client/k8s"
kubeinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"

zfsapi "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1"
clientset "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset"
informers "github.com/openebs/zfs-localpv/pkg/generated/informer/externalversions"
"github.com/openebs/zfs-localpv/pkg/version"
kubeinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"

"github.com/container-storage-interface/spec/lib/go/csi"
analytics "github.com/openebs/google-analytics-4/usage"
"github.com/openebs/lib-csi/pkg/common/errors"
"github.com/openebs/lib-csi/pkg/common/helpers"
schd "github.com/openebs/lib-csi/pkg/scheduler"
"golang.org/x/net/context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand All @@ -41,14 +46,10 @@ import (
"k8s.io/client-go/tools/cache"
"k8s.io/klog/v2"

analytics "github.com/openebs/google-analytics-4/usage"
errors "github.com/openebs/lib-csi/pkg/common/errors"
"github.com/openebs/lib-csi/pkg/common/helpers"
schd "github.com/openebs/lib-csi/pkg/scheduler"
"github.com/openebs/zfs-localpv/pkg/builder/snapbuilder"
"github.com/openebs/zfs-localpv/pkg/builder/volbuilder"
csipayload "github.com/openebs/zfs-localpv/pkg/response"
zfs "github.com/openebs/zfs-localpv/pkg/zfs"
"github.com/openebs/zfs-localpv/pkg/zfs"
)

// size constants
Expand All @@ -59,8 +60,9 @@ const (
Gi = 1024 * 1024 * 1024

// Ping event is sent periodically
Ping string = "zfs-ping"

Ping string = "ping"
// Heartbeat message.
Heartbeat string = "heartbeat"
// DefaultCASType Event application name constant for volume event
DefaultCASType string = "zfs-localpv"

Expand Down Expand Up @@ -133,7 +135,8 @@ func (cs *controller) init() error {
if zfs.GoogleAnalyticsEnabled == "true" {
analytics.RegisterVersionGetter(version.GetVersionDetails)
analytics.New().CommonBuild(DefaultCASType).InstallBuilder(true).Send()
go analytics.PingCheck(DefaultCASType, Ping)
go analytics.PingCheck(DefaultCASType, Ping, false)
go analytics.PingCheck(DefaultCASType, Heartbeat, true)
}

// wait for all the caches to be populated.
Expand All @@ -159,8 +162,7 @@ func sendEventOrIgnore(pvcName, pvName, capacity, method string) {
analytics.New().CommonBuild(DefaultCASType).ApplicationBuilder().
SetVolumeName(pvName).
SetVolumeClaimName(pvcName).
SetLabel(analytics.EventLabelCapacity).
SetReplicaCount(LocalPVReplicaCount, method).
SetReplicaCount(LocalPVReplicaCount).
SetCategory(method).
SetVolumeCapacity(capacity).Send()
}
Expand Down

0 comments on commit b4c621b

Please sign in to comment.