Skip to content

Commit

Permalink
fix(analytics): respect environment variable to disable reporting eve…
Browse files Browse the repository at this point in the history
…nt analytics

Signed-off-by: Ethan Mosbaugh <[email protected]>
  • Loading branch information
emosbaugh authored and niladrih committed Nov 7, 2024
1 parent f0f4acc commit dbc556a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/210-disable-event-analytics
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix respect OPENEBS_IO_ENABLE_ANALYTICS environment variable to disable reporting event analytics.
21 changes: 12 additions & 9 deletions cmd/provisioner-localpv/app/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
analytics "github.com/openebs/google-analytics-4/usage"
"github.com/openebs/maya/pkg/alertlog"
mconfig "github.com/openebs/maya/pkg/apis/openebs.io/v1alpha1"
menv "github.com/openebs/maya/pkg/env/v1alpha1"
"github.com/pkg/errors"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -192,15 +193,17 @@ func (p *Provisioner) Delete(ctx context.Context, pv *v1.PersistentVolume) (err

// sendEventOrIgnore sends anonymous local-pv provision/delete events
func sendEventOrIgnore(pvcName, pvName, capacity, stgType, method string) {
stgType = "local-" + stgType

analytics.New().CommonBuild(stgType).ApplicationBuilder().
SetVolumeName(pvName).
SetVolumeClaimName(pvcName).
SetReplicaCount(DefaultUnknownReplicaCount).
SetCategory(method).
SetVolumeCapacity(capacity).
Send()
if menv.Truthy(menv.OpenEBSEnableAnalytics) {
stgType = "local-" + stgType

analytics.New().CommonBuild(stgType).ApplicationBuilder().
SetVolumeName(pvName).
SetVolumeClaimName(pvcName).
SetReplicaCount(DefaultUnknownReplicaCount).
SetCategory(method).
SetVolumeCapacity(capacity).
Send()
}
}

// validateVolumeSource validates datasource field of the pvc.
Expand Down

0 comments on commit dbc556a

Please sign in to comment.