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 <[email protected]>
  • Loading branch information
niladrih committed Jul 1, 2024
1 parent c36087b commit b167498
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 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.1
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.1 h1:+DgJjcPM3uVyWp9VxvNQgNXCWWv0OFhopijFdPVVX9Q=
github.com/openebs/google-analytics-4 v0.2.1/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
36 changes: 18 additions & 18 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,32 @@ import (
"strings"
"time"

k8sapi "github.com/openebs/lib-csi/pkg/client/k8s"
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"
k8sapi "github.com/openebs/lib-csi/pkg/client/k8s"
"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"
k8serror "k8s.io/apimachinery/pkg/api/errors"
apimeta "k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/labels"
kubeinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"

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"
zfsapi "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1"
"github.com/openebs/zfs-localpv/pkg/builder/snapbuilder"
"github.com/openebs/zfs-localpv/pkg/builder/volbuilder"
clientset "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset"
informers "github.com/openebs/zfs-localpv/pkg/generated/informer/externalversions"
csipayload "github.com/openebs/zfs-localpv/pkg/response"
zfs "github.com/openebs/zfs-localpv/pkg/zfs"
"github.com/openebs/zfs-localpv/pkg/version"
"github.com/openebs/zfs-localpv/pkg/zfs"
)

// size constants
Expand All @@ -60,7 +59,8 @@ const (

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

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

Expand Down Expand Up @@ -133,7 +133,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 +160,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 b167498

Please sign in to comment.