diff --git a/go.mod b/go.mod index 6703011c..594667ab 100644 --- a/go.mod +++ b/go.mod @@ -325,3 +325,5 @@ replace ( k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.24.2 k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.24.2 ) + +replace github.com/kubefirst/metrics-client => /Users/jared/git/kubefirst/github/metrics-client diff --git a/internal/controller/argocd.go b/internal/controller/argocd.go index 95ef6153..e64bbcd1 100644 --- a/internal/controller/argocd.go +++ b/internal/controller/argocd.go @@ -13,7 +13,6 @@ import ( argocdapi "github.com/argoproj/argo-cd/v2/pkg/client/clientset/versioned" awsext "github.com/kubefirst/kubefirst-api/extensions/aws" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/metrics-client/pkg/telemetry" "github.com/kubefirst/runtime/pkg" "github.com/kubefirst/runtime/pkg/argocd" @@ -57,16 +56,16 @@ func (clctrl *ClusterController) InstallArgoCD() error { argoCDInstallPath := fmt.Sprintf("github.com:kubefirst/manifests/argocd/cloud?ref=%s", pkg.KubefirstManifestRepoRef) log.Infof("installing argocd") - telemetry.SendCountMetric(clctrl.Telemetry, metrics.ArgoCDInstallStarted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.ArgoCDInstallStarted, err.Error()) err = argocd.ApplyArgoCDKustomize(kcfg.Clientset, argoCDInstallPath) if err != nil { - telemetry.SendCountMetric(clctrl.Telemetry, metrics.ArgoCDInstallFailed, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.ArgoCDInstallFailed, err.Error()) return err } - telemetry.SendCountMetric(clctrl.Telemetry, metrics.ArgoCDInstallCompleted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.ArgoCDInstallCompleted, err.Error()) // Wait for ArgoCD to be ready _, err = k8s.VerifyArgoCDReadiness(kcfg.Clientset, true, 300) @@ -179,7 +178,6 @@ func (clctrl *ClusterController) DeployRegistryApplication() error { return err } - if !cl.ArgoCDCreateRegistryCheck { var kcfg *k8s.KubernetesClient @@ -196,7 +194,7 @@ func (clctrl *ClusterController) DeployRegistryApplication() error { } } - telemetry.SendCountMetric(clctrl.Telemetry, metrics.CreateRegistryStarted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.CreateRegistryStarted, err.Error()) argocdClient, err := argocdapi.NewForConfig(kcfg.RestConfig) if err != nil { return err @@ -241,7 +239,7 @@ func (clctrl *ClusterController) DeployRegistryApplication() error { _, _ = argocdClient.ArgoprojV1alpha1().Applications("argocd").Create(context.Background(), registryApplicationObject, metav1.CreateOptions{}) - telemetry.SendCountMetric(clctrl.Telemetry, metrics.CreateRegistryCompleted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.CreateRegistryCompleted, err.Error()) err = clctrl.MdbCl.UpdateCluster(clctrl.ClusterName, "argocd_create_registry_check", true) if err != nil { diff --git a/internal/controller/cluster.go b/internal/controller/cluster.go index 7262852a..140bc371 100644 --- a/internal/controller/cluster.go +++ b/internal/controller/cluster.go @@ -19,7 +19,6 @@ import ( terraformext "github.com/kubefirst/kubefirst-api/extensions/terraform" vultrext "github.com/kubefirst/kubefirst-api/extensions/vultr" gitShim "github.com/kubefirst/kubefirst-api/internal/gitShim" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/kubefirst-api/pkg/providerConfigs" pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types" "github.com/kubefirst/metrics-client/pkg/telemetry" @@ -51,7 +50,7 @@ func (clctrl *ClusterController) CreateCluster() error { tfEntrypoint := clctrl.ProviderConfig.GitopsDir + fmt.Sprintf("/terraform/%s", clctrl.CloudProvider) tfEnvs := map[string]string{} - telemetry.SendCountMetric(clctrl.Telemetry, metrics.CloudTerraformApplyStarted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.CloudTerraformApplyStarted, err.Error()) log.Infof("creating %s cluster", clctrl.CloudProvider) @@ -87,12 +86,12 @@ func (clctrl *ClusterController) CreateCluster() error { if err != nil { return err } - telemetry.SendCountMetric(clctrl.Telemetry, metrics.CloudTerraformApplyFailed, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.CloudTerraformApplyFailed, err.Error()) return fmt.Errorf(msg) } log.Infof("created %s cloud resources", clctrl.CloudProvider) - telemetry.SendCountMetric(clctrl.Telemetry, metrics.CloudTerraformApplyCompleted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.CloudTerraformApplyCompleted, err.Error()) err = clctrl.MdbCl.UpdateCluster(clctrl.ClusterName, "cloud_terraform_apply_failed_check", false) if err != nil { diff --git a/internal/controller/controller.go b/internal/controller/controller.go index 8ccb5492..cf6e4c54 100644 --- a/internal/controller/controller.go +++ b/internal/controller/controller.go @@ -19,7 +19,6 @@ import ( "github.com/kubefirst/kubefirst-api/internal/utils" google "github.com/kubefirst/kubefirst-api/pkg/google" "github.com/kubefirst/kubefirst-api/pkg/handlers" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/kubefirst-api/pkg/providerConfigs" "github.com/kubefirst/kubefirst-api/pkg/segment" pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types" @@ -107,8 +106,7 @@ type ClusterController struct { MdbCl *db.MongoDBClient // Telemetry - Telemetry *telemetry.SegmentClient - UseTelemetry bool + SegmentClient *telemetry.SegmentClient // Provider clients AwsClient *awsinternal.AWSConfiguration @@ -149,9 +147,9 @@ func (clctrl *ClusterController) InitController(def *pkgtypes.ClusterDefinition) } if os.Getenv("USE_TELEMETRY") == "false" { - clctrl.UseTelemetry = false + clctrl.SegmentClient.UseTelemetry = false } else { - clctrl.UseTelemetry = true + clctrl.SegmentClient.UseTelemetry = true } // Telemetry handle @@ -172,7 +170,7 @@ func (clctrl *ClusterController) InitController(def *pkgtypes.ClusterDefinition) MachineID: machineID, ErrorMessage: "", UserId: machineID, - MetricName: metrics.ClusterInstallStarted, + MetricName: telemetry.ClusterInstallStarted, }, Client: analytics.New(segment.SegmentIOWriteKey), } @@ -181,8 +179,8 @@ func (clctrl *ClusterController) InitController(def *pkgtypes.ClusterDefinition) } defer segClient.Client.Close() - if clctrl.UseTelemetry { - telemetry.SendCountMetric(&segClient, metrics.ClusterInstallStarted, err.Error()) + if clctrl.SegmentClient.UseTelemetry { + telemetry.SendCountMetric(&segClient, telemetry.ClusterInstallStarted, err.Error()) } clctrl.Telemetry = &segClient @@ -293,16 +291,16 @@ func (clctrl *ClusterController) InitController(def *pkgtypes.ClusterDefinition) } if os.Getenv("USE_TELEMETRY") == "false" { - clctrl.UseTelemetry = false + clctrl.SegmentClient.UseTelemetry = false } else { - clctrl.UseTelemetry = true + clctrl.SegmentClient.UseTelemetry = true } // Write cluster record if it doesn't exist cl := pkgtypes.Cluster{ ID: primitive.NewObjectID(), CreationTimestamp: fmt.Sprintf("%v", primitive.NewDateTimeFromTime(time.Now().UTC())), - UseTelemetry: clctrl.UseTelemetry, + UseTelemetry: clctrl.SegmentClient.UseTelemetry, Status: constants.ClusterStatusProvisioning, AlertsEmail: clctrl.AlertsEmail, ClusterName: clctrl.ClusterName, diff --git a/internal/controller/domain.go b/internal/controller/domain.go index 0be4d37e..57e0950a 100644 --- a/internal/controller/domain.go +++ b/internal/controller/domain.go @@ -11,7 +11,6 @@ import ( "fmt" cloudflare_api "github.com/cloudflare/cloudflare-go" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/metrics-client/pkg/telemetry" "github.com/kubefirst/runtime/pkg/civo" "github.com/kubefirst/runtime/pkg/digitalocean" @@ -28,7 +27,7 @@ func (clctrl *ClusterController) DomainLivenessTest() error { } if !cl.DomainLivenessCheck { - telemetry.SendCountMetric(clctrl.Telemetry, metrics.DomainLivenessStarted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.DomainLivenessStarted, err.Error()) switch clctrl.DnsProvider { case "aws": @@ -47,7 +46,7 @@ func (clctrl *ClusterController) DomainLivenessTest() error { // domain id domainId, err := civoConf.GetDNSInfo(clctrl.DomainName, clctrl.CloudRegion) if err != nil { - telemetry.SendCountMetric(clctrl.Telemetry, metrics.DomainLivenessFailed, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.DomainLivenessFailed, err.Error()) log.Info(err.Error()) } @@ -122,7 +121,7 @@ func (clctrl *ClusterController) DomainLivenessTest() error { return err } - telemetry.SendCountMetric(clctrl.Telemetry, metrics.DomainLivenessCompleted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.DomainLivenessCompleted, err.Error()) log.Infof("domain %s verified", clctrl.DomainName) } diff --git a/internal/controller/git.go b/internal/controller/git.go index c0cd1b65..5ddbdbee 100644 --- a/internal/controller/git.go +++ b/internal/controller/git.go @@ -17,7 +17,6 @@ import ( terraformext "github.com/kubefirst/kubefirst-api/extensions/terraform" vultrext "github.com/kubefirst/kubefirst-api/extensions/vultr" gitShim "github.com/kubefirst/kubefirst-api/internal/gitShim" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/metrics-client/pkg/telemetry" "github.com/kubefirst/runtime/pkg/gitlab" log "github.com/sirupsen/logrus" @@ -73,7 +72,7 @@ func (clctrl *ClusterController) RunGitTerraform() error { } // //* create teams and repositories in github - telemetry.SendCountMetric(clctrl.Telemetry, metrics.GitTerraformApplyStarted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.GitTerraformApplyStarted, err.Error()) log.Infof("Creating %s resources with terraform", clctrl.GitProvider) @@ -114,12 +113,12 @@ func (clctrl *ClusterController) RunGitTerraform() error { if err != nil { msg := fmt.Sprintf("error creating %s resources with terraform %s: %s", clctrl.GitProvider, tfEntrypoint, err) log.Error(msg) - telemetry.SendCountMetric(clctrl.Telemetry, metrics.GitTerraformApplyFailed, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.GitTerraformApplyFailed, err.Error()) return fmt.Errorf(msg) } log.Infof("created git projects and groups for %s.com/%s", clctrl.GitProvider, clctrl.GitAuth.Owner) - telemetry.SendCountMetric(clctrl.Telemetry, metrics.GitTerraformApplyCompleted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.GitTerraformApplyCompleted, err.Error()) err = clctrl.MdbCl.UpdateCluster(clctrl.ClusterName, "git_terraform_apply_check", true) if err != nil { diff --git a/internal/controller/kbot.go b/internal/controller/kbot.go index 38442248..baefbe0f 100644 --- a/internal/controller/kbot.go +++ b/internal/controller/kbot.go @@ -9,7 +9,6 @@ package controller import ( "os" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/metrics-client/pkg/telemetry" internalssh "github.com/kubefirst/runtime/pkg/ssh" log "github.com/sirupsen/logrus" @@ -35,7 +34,7 @@ func (clctrl *ClusterController) InitializeBot() error { clctrl.GitAuth.PrivateKey, clctrl.GitAuth.PublicKey, err = internalssh.CreateSshKeyPair() if err != nil { log.Errorf("error generating ssh keys: %s", err) - telemetry.SendCountMetric(clctrl.Telemetry, metrics.KbotSetupFailed, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.KbotSetupFailed, err.Error()) return err } diff --git a/internal/controller/repository.go b/internal/controller/repository.go index 067415d1..17529b3f 100644 --- a/internal/controller/repository.go +++ b/internal/controller/repository.go @@ -14,7 +14,6 @@ import ( "github.com/go-git/go-git/v5" githttps "github.com/go-git/go-git/v5/plumbing/transport/http" google "github.com/kubefirst/kubefirst-api/pkg/google" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/kubefirst-api/pkg/providerConfigs" "github.com/kubefirst/metrics-client/pkg/telemetry" "github.com/kubefirst/runtime/pkg/civo" @@ -195,7 +194,7 @@ func (clctrl *ClusterController) RepositoryPush() error { gitopsDir := clctrl.ProviderConfig.GitopsDir metaphorDir := clctrl.ProviderConfig.MetaphorDir - telemetry.SendCountMetric(clctrl.Telemetry, metrics.GitopsRepoPushStarted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.GitopsRepoPushStarted, err.Error()) gitopsRepo, err := git.PlainOpen(gitopsDir) if err != nil { log.Infof("error opening repo at: %s", gitopsDir) @@ -251,7 +250,7 @@ func (clctrl *ClusterController) RepositoryPush() error { ) if err != nil { msg := fmt.Sprintf("error pushing detokenized gitops repository to remote %s: %s", clctrl.ProviderConfig.DestinationGitopsRepoURL, err) - telemetry.SendCountMetric(clctrl.Telemetry, metrics.GitopsRepoPushFailed, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.GitopsRepoPushFailed, err.Error()) return fmt.Errorf(msg) } @@ -267,14 +266,14 @@ func (clctrl *ClusterController) RepositoryPush() error { ) if err != nil { msg := fmt.Sprintf("error pushing detokenized metaphor repository to remote %s: %s", clctrl.ProviderConfig.DestinationMetaphorRepoURL, err) - telemetry.SendCountMetric(clctrl.Telemetry, metrics.GitopsRepoPushFailed, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.GitopsRepoPushFailed, err.Error()) return fmt.Errorf(msg) } log.Infof("successfully pushed gitops and metaphor repositories to git@%s/%s", clctrl.GitHost, clctrl.GitAuth.Owner) // todo delete the local gitops repo and re-clone it // todo that way we can stop worrying about which origin we're going to push to - telemetry.SendCountMetric(clctrl.Telemetry, metrics.GitopsRepoPushCompleted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.GitopsRepoPushCompleted, err.Error()) err = clctrl.MdbCl.UpdateCluster(clctrl.ClusterName, "gitops_pushed_check", true) if err != nil { diff --git a/internal/controller/state.go b/internal/controller/state.go index 8e7fb171..9c181671 100644 --- a/internal/controller/state.go +++ b/internal/controller/state.go @@ -12,7 +12,6 @@ import ( "os" "strings" - "github.com/kubefirst/kubefirst-api/pkg/metrics" pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types" "github.com/kubefirst/metrics-client/pkg/telemetry" "github.com/kubefirst/runtime/pkg/civo" @@ -38,7 +37,7 @@ func (clctrl *ClusterController) StateStoreCredentials() error { } var stateStoreData pkgtypes.StateStoreCredentials - telemetry.SendCountMetric(clctrl.Telemetry, metrics.StateStoreCredentialsCreateStarted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.StateStoreCredentialsCreateStarted, err.Error()) if !cl.StateStoreCredsCheck { switch clctrl.CloudProvider { @@ -101,7 +100,7 @@ func (clctrl *ClusterController) StateStoreCredentials() error { if err != nil { msg := fmt.Sprintf("error creating spaces bucket %s: %s", clctrl.KubefirstStateStoreBucketName, err) log.Error(msg) - telemetry.SendCountMetric(clctrl.Telemetry, metrics.StateStoreCredentialsCreateFailed, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.StateStoreCredentialsCreateFailed, err.Error()) return fmt.Errorf(msg) } @@ -127,7 +126,7 @@ func (clctrl *ClusterController) StateStoreCredentials() error { if err != nil { msg := fmt.Sprintf("error creating google bucket %s: %s", clctrl.KubefirstStateStoreBucketName, err) log.Error() - telemetry.SendCountMetric(clctrl.Telemetry, metrics.StateStoreCredentialsCreateFailed, msg) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.StateStoreCreateFailed, msg) return fmt.Errorf(msg) } @@ -142,7 +141,7 @@ func (clctrl *ClusterController) StateStoreCredentials() error { objst, err := vultrConf.CreateObjectStorage(clctrl.KubefirstStateStoreBucketName) if err != nil { - telemetry.SendCountMetric(clctrl.Telemetry, metrics.StateStoreCredentialsCreateFailed, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.StateStoreCreateFailed, err.Error()) log.Error(err.Error()) return err } @@ -203,14 +202,14 @@ func (clctrl *ClusterController) StateStoreCreate() error { Context: context.Background(), } - telemetry.SendCountMetric(clctrl.Telemetry, metrics.StateStoreCreateStarted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.StateStoreCreateStarted, err.Error()) accessKeyId := cl.StateStoreCredentials.AccessKeyID log.Infof("access key id %s", accessKeyId) bucket, err := civoConf.CreateStorageBucket(accessKeyId, clctrl.KubefirstStateStoreBucketName, clctrl.CloudRegion) if err != nil { - telemetry.SendCountMetric(clctrl.Telemetry, metrics.StateStoreCreateFailed, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.StateStoreCreateFailed, err.Error()) log.Error(err.Error()) return err } @@ -230,7 +229,7 @@ func (clctrl *ClusterController) StateStoreCreate() error { return err } - telemetry.SendCountMetric(clctrl.Telemetry, metrics.StateStoreCreateCompleted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.StateStoreCreateCompleted, err.Error()) log.Infof("%s state store bucket created", clctrl.CloudProvider) } } diff --git a/internal/controller/users.go b/internal/controller/users.go index a00982a2..1824da99 100644 --- a/internal/controller/users.go +++ b/internal/controller/users.go @@ -15,7 +15,6 @@ import ( googleext "github.com/kubefirst/kubefirst-api/extensions/google" terraformext "github.com/kubefirst/kubefirst-api/extensions/terraform" vultrext "github.com/kubefirst/kubefirst-api/extensions/vultr" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/metrics-client/pkg/telemetry" "github.com/kubefirst/runtime/pkg/k8s" log "github.com/sirupsen/logrus" @@ -53,7 +52,7 @@ func (clctrl *ClusterController) RunUsersTerraform() error { } } - telemetry.SendCountMetric(clctrl.Telemetry, metrics.UsersTerraformApplyStarted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.UsersTerraformApplyStarted, err.Error()) log.Info("applying users terraform") tfEnvs := map[string]string{} @@ -81,11 +80,11 @@ func (clctrl *ClusterController) RunUsersTerraform() error { err = terraformext.InitApplyAutoApprove(terraformClient, tfEntrypoint, tfEnvs) if err != nil { log.Errorf("error applying users terraform: %s", err) - telemetry.SendCountMetric(clctrl.Telemetry, metrics.UsersTerraformApplyFailed, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.UsersTerraformApplyFailed, err.Error()) return err } log.Info("executed users terraform successfully") - telemetry.SendCountMetric(clctrl.Telemetry, metrics.UsersTerraformApplyCompleted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.UsersTerraformApplyCompleted, err.Error()) clctrl.VaultAuth.RootToken = tfEnvs["VAULT_TOKEN"] err = clctrl.MdbCl.UpdateCluster(clctrl.ClusterName, "vault_auth.root_token", clctrl.VaultAuth.RootToken) diff --git a/internal/controller/vault.go b/internal/controller/vault.go index bc061076..fab02d22 100644 --- a/internal/controller/vault.go +++ b/internal/controller/vault.go @@ -22,7 +22,6 @@ import ( googleext "github.com/kubefirst/kubefirst-api/extensions/google" terraformext "github.com/kubefirst/kubefirst-api/extensions/terraform" vultrext "github.com/kubefirst/kubefirst-api/extensions/vultr" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/metrics-client/pkg/telemetry" "github.com/kubefirst/runtime/pkg/k8s" vault "github.com/kubefirst/runtime/pkg/vault" @@ -97,7 +96,7 @@ func (clctrl *ClusterController) InitializeVault() error { } } - telemetry.SendCountMetric(clctrl.Telemetry, metrics.VaultInitializationStarted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.VaultInitializationStarted, err.Error()) switch clctrl.CloudProvider { case "aws", "google": @@ -151,11 +150,11 @@ func (clctrl *ClusterController) InitializeVault() error { _, err = k8s.WaitForJobComplete(kcfg.Clientset, job, 240) if err != nil { msg := fmt.Sprintf("could not run vault unseal job: %s", err) - telemetry.SendCountMetric(clctrl.Telemetry, metrics.VaultInitializationFailed, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.VaultInitializationFailed, err.Error()) log.Error(msg) } } - telemetry.SendCountMetric(clctrl.Telemetry, metrics.VaultInitializationCompleted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.VaultInitializationCompleted, err.Error()) err = clctrl.MdbCl.UpdateCluster(clctrl.ClusterName, "vault_initialized_check", true) if err != nil { @@ -197,7 +196,7 @@ func (clctrl *ClusterController) RunVaultTerraform() error { return err } } - telemetry.SendCountMetric(clctrl.Telemetry, metrics.VaultTerraformApplyStarted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.VaultTerraformApplyStarted, err.Error()) tfEnvs := map[string]string{} @@ -251,12 +250,12 @@ func (clctrl *ClusterController) RunVaultTerraform() error { err = terraformext.InitApplyAutoApprove(terraformClient, tfEntrypoint, tfEnvs) if err != nil { log.Errorf("error applying vault terraform: %s", err) - telemetry.SendCountMetric(clctrl.Telemetry, metrics.VaultTerraformApplyFailed, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.VaultTerraformApplyFailed, err.Error()) return err } log.Info("vault terraform executed successfully") - telemetry.SendCountMetric(clctrl.Telemetry, metrics.VaultTerraformApplyCompleted, err.Error()) + telemetry.SendCountMetric(clctrl.SegmentClient, telemetry.VaultTerraformApplyCompleted, err.Error()) err = clctrl.MdbCl.UpdateCluster(clctrl.ClusterName, "vault_terraform_apply_check", true) if err != nil { diff --git a/internal/router/api/v1/cluster.go b/internal/router/api/v1/cluster.go index a77ca673..a35d3fb5 100644 --- a/internal/router/api/v1/cluster.go +++ b/internal/router/api/v1/cluster.go @@ -20,7 +20,6 @@ import ( "github.com/kubefirst/kubefirst-api/internal/services" "github.com/kubefirst/kubefirst-api/internal/types" "github.com/kubefirst/kubefirst-api/internal/utils" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/kubefirst-api/pkg/segment" pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types" "github.com/kubefirst/kubefirst-api/providers/aws" @@ -81,7 +80,7 @@ func DeleteCluster(c *gin.Context) { MachineID: machineID, ErrorMessage: err.Error(), UserId: machineID, - MetricName: metrics.ClusterDeleteStarted, + MetricName: telemetry.ClusterDeleteStarted, }, Client: analytics.New(segment.SegmentIOWriteKey), } diff --git a/internal/router/api/v1/telemetry.go b/internal/router/api/v1/telemetry.go index 3cf2fbcf..e963fe34 100644 --- a/internal/router/api/v1/telemetry.go +++ b/internal/router/api/v1/telemetry.go @@ -14,7 +14,6 @@ import ( "github.com/gin-gonic/gin" "github.com/kubefirst/kubefirst-api/internal/db" "github.com/kubefirst/kubefirst-api/internal/types" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/kubefirst-api/pkg/segment" "github.com/kubefirst/metrics-client/pkg/telemetry" "github.com/segmentio/analytics-go" @@ -54,7 +53,7 @@ func PostTelemetry(c *gin.Context) { MachineID: machineID, ErrorMessage: "", UserId: machineID, - MetricName: metrics.ClusterDeleteStarted, + MetricName: telemetry.ClusterDeleteStarted, }, Client: analytics.New(segment.SegmentIOWriteKey), } diff --git a/internal/telemetry/heartbeat.go b/internal/telemetry/heartbeat.go index 68e467ef..a3a90f70 100644 --- a/internal/telemetry/heartbeat.go +++ b/internal/telemetry/heartbeat.go @@ -5,18 +5,17 @@ import ( "github.com/kubefirst/kubefirst-api/internal/constants" "github.com/kubefirst/kubefirst-api/internal/db" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/kubefirst-api/pkg/segment" "github.com/kubefirst/metrics-client/pkg/telemetry" "github.com/segmentio/analytics-go" ) func Heartbeat(segmentClient *telemetry.SegmentClient, dbClient *db.MongoDBClient) { - telemetry.SendCountMetric(segmentClient, metrics.KubefirstHeartbeat, "") + telemetry.SendCountMetric(segmentClient, telemetry.KubefirstHeartbeat, "") HeartbeatWorkloadClusters(segmentClient, dbClient) for range time.Tick(time.Second * 30) { - telemetry.SendCountMetric(segmentClient, metrics.KubefirstHeartbeat, "") + telemetry.SendCountMetric(segmentClient, telemetry.KubefirstHeartbeat, "") HeartbeatWorkloadClusters(segmentClient, dbClient) } } @@ -45,13 +44,13 @@ func HeartbeatWorkloadClusters(segmentClient *telemetry.SegmentClient, dbClient MachineID: segmentClient.TelemetryEvent.MachineID, ErrorMessage: "", UserId: segmentClient.TelemetryEvent.MachineID, - MetricName: metrics.KubefirstHeartbeat, + MetricName: telemetry.KubefirstHeartbeat, }, Client: analytics.New(segment.SegmentIOWriteKey), } defer workloadClient.Client.Close() - telemetry.SendCountMetric(&workloadClient, metrics.KubefirstHeartbeat, "") + telemetry.SendCountMetric(&workloadClient, telemetry.KubefirstHeartbeat, "") } } } diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go deleted file mode 100644 index fd072f90..00000000 --- a/pkg/metrics/metrics.go +++ /dev/null @@ -1,77 +0,0 @@ -package metrics - -const ( - // Heartbeat - KubefirstHeartbeat = "kubefirst.heartbeat" - - // Install - KubefirstInstalled = "kubefirst.installed" - - // Init - InitStarted = "kubefirst.init.started" - InitCompleted = "kubefirst.init.completed" - - CloudCredentialsCheckStarted = "kubefirst.init.cloud_credentials_check.started" - CloudCredentialsCheckCompleted = "kubefirst.init.cloud_credentials_check.completed" - CloudCredentialsCheckFailed = "kubefirst.init.cloud_credentials_check.failed" - - DomainLivenessStarted = "kubefirst.init.domain_liveness.started" - DomainLivenessCompleted = "kubefirst.init.domain_liveness.completed" - DomainLivenessFailed = "kubefirst.init.domain_liveness.failed" - - StateStoreCreateStarted = "kubefirst.init.state_store_create.started" - StateStoreCreateCompleted = "kubefirst.init.state_store_create.completed" - StateStoreCreateFailed = "kubefirst.init.state_store_create.failed" - - StateStoreCredentialsCreateStarted = "kubefirst.init.state_store_credentials_create.started" - StateStoreCredentialsCreateCompleted = "kubefirst.init.state_store_credentials_create.completed" - StateStoreCredentialsCreateFailed = "kubefirst.init.state_store_credentials_create.failed" - - GitCredentialsCheckStarted = "kubefirst.init.git_credentials_check.started" - GitCredentialsCheckCompleted = "kubefirst.init.git_credentials_check.completed" - GitCredentialsCheckFailed = "kubefirst.init.git_credentials_check.failed" - - KbotSetupStarted = "kubefirst.init.kbot_setup.started" - KbotSetupCompleted = "kubefirst.init.kbot_setup.completed" - KbotSetupFailed = "kubefirst.init.kbot_setup.failed" - - // Create - ClusterInstallStarted = "kubefirst.cluster_install.started" - ClusterInstallCompleted = "kubefirst.cluster_install.completed" - - GitTerraformApplyStarted = "kubefirst.git_terraform_apply.started" - GitTerraformApplyCompleted = "kubefirst.git_terraform_apply.completed" - GitTerraformApplyFailed = "kubefirst.git_terraform_apply.failed" - - GitopsRepoPushStarted = "kubefirst.gitops_repo_push.started" - GitopsRepoPushCompleted = "kubefirst.gitops_repo_push.completed" - GitopsRepoPushFailed = "kubefirst.gitops_repo_push.failed" - - CloudTerraformApplyStarted = "kubefirst.cloud_terraform_apply.started" - CloudTerraformApplyCompleted = "kubefirst.cloud_terraform_apply.completed" - CloudTerraformApplyFailed = "kubefirst.cloud_terraform_apply.failed" - - ArgoCDInstallStarted = "kubefirst.argocd_install.started" - ArgoCDInstallCompleted = "kubefirst.argocd_install.completed" - ArgoCDInstallFailed = "kubefirst.argocd_install.failed" - - CreateRegistryStarted = "kubefirst.create_registry.started" - CreateRegistryCompleted = "kubefirst.create_registry.completed" - CreateRegistryFailed = "kubefirst.create_registry.failed" - - VaultInitializationStarted = "kubefirst.vault_initialization.started" - VaultInitializationCompleted = "kubefirst.vault_initialization.completed" - VaultInitializationFailed = "kubefirst.vault_initialization.failed" - - VaultTerraformApplyStarted = "kubefirst.vault_terraform_apply.started" - VaultTerraformApplyCompleted = "kubefirst.vault_terraform_apply.completed" - VaultTerraformApplyFailed = "kubefirst.vault_terraform_apply.failed" - - UsersTerraformApplyStarted = "kubefirst.users_terraform_apply.started" - UsersTerraformApplyCompleted = "kubefirst.users_terraform_apply.completed" - UsersTerraformApplyFailed = "kubefirst.users_terraform_apply.failed" - - // Delete - ClusterDeleteStarted = "kubefirst.cluster_delete.started" - ClusterDeleteCompleted = "kubefirst.cluster_delete.completed" -) diff --git a/pkg/segment/segment.go b/pkg/segment/segment.go index b0535fd5..c05d9928 100644 --- a/pkg/segment/segment.go +++ b/pkg/segment/segment.go @@ -4,7 +4,6 @@ import ( "os" "github.com/denisbrodbeck/machineid" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/runtime/pkg/segment" "github.com/kubefirst/metrics-client/pkg/telemetry" @@ -12,11 +11,7 @@ import ( ) const ( - // SegmentIO constants - // SegmentIOWriteKey The write key is the unique identifier for a source that tells Segment which source data comes - // from, to which workspace the data belongs, and which destinations should receive the data. - SegmentIOWriteKey = "0gAYkX5RV3vt7s4pqCOOsDb6WHPLT30M" - kubefirstClient string = "api" + kubefirstClient string = "api" ) func InitClient() *telemetry.SegmentClient { @@ -38,7 +33,7 @@ func InitClient() *telemetry.SegmentClient { MachineID: machineID, ErrorMessage: "", UserId: machineID, - MetricName: metrics.KubefirstHeartbeat, + MetricName: telemetry.KubefirstHeartbeat, }, Client: analytics.New(segment.SegmentIOWriteKey), } diff --git a/providers/aws/create.go b/providers/aws/create.go index 91fafaa3..fea4e3b2 100644 --- a/providers/aws/create.go +++ b/providers/aws/create.go @@ -12,7 +12,6 @@ import ( "github.com/kubefirst/kubefirst-api/internal/controller" "github.com/kubefirst/kubefirst-api/internal/db" "github.com/kubefirst/kubefirst-api/internal/services" - "github.com/kubefirst/kubefirst-api/pkg/metrics" pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types" "github.com/kubefirst/metrics-client/pkg/telemetry" awsinternal "github.com/kubefirst/runtime/pkg/aws" @@ -257,7 +256,7 @@ func CreateAWSCluster(definition *pkgtypes.ClusterDefinition) error { log.Info("cluster creation complete") - telemetry.SendCountMetric(ctrl.Telemetry, metrics.ClusterInstallCompleted, err.Error()) + telemetry.SendCountMetric(ctrl.Telemetry, telemetry.ClusterInstallCompleted, err.Error()) // Create default service entries cl, _ := db.Client.GetCluster(ctrl.ClusterName) diff --git a/providers/aws/delete.go b/providers/aws/delete.go index 09238176..2bbc6e60 100644 --- a/providers/aws/delete.go +++ b/providers/aws/delete.go @@ -19,7 +19,6 @@ import ( "github.com/kubefirst/kubefirst-api/internal/constants" "github.com/kubefirst/kubefirst-api/internal/db" "github.com/kubefirst/kubefirst-api/internal/errors" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/kubefirst-api/pkg/providerConfigs" pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types" "github.com/kubefirst/metrics-client/pkg/telemetry" @@ -42,7 +41,7 @@ func DeleteAWSCluster(cl *pkgtypes.Cluster, segmentClient *telemetry.SegmentClie log.SetReportCaller(false) log.SetOutput(os.Stdout) - telemetry.SendCountMetric(segmentClient, metrics.ClusterDeleteStarted, "") + telemetry.SendCountMetric(segmentClient, telemetry.ClusterDeleteStarted, "") // Instantiate aws config config := providerConfigs.GetConfig(cl.ClusterName, cl.DomainName, cl.GitProvider, cl.GitAuth.Owner, cl.GitProtocol, cl.CloudflareAuth.APIToken, cl.CloudflareAuth.OriginCaIssuerKey) @@ -254,7 +253,7 @@ func DeleteAWSCluster(cl *pkgtypes.Cluster, segmentClient *telemetry.SegmentClie } } - telemetry.SendCountMetric(segmentClient, metrics.ClusterDeleteCompleted, "") + telemetry.SendCountMetric(segmentClient, telemetry.ClusterDeleteCompleted, "") err = db.Client.UpdateCluster(cl.ClusterName, "status", constants.ClusterStatusDeleted) if err != nil { diff --git a/providers/civo/create.go b/providers/civo/create.go index c5e34714..f7a7a2bf 100644 --- a/providers/civo/create.go +++ b/providers/civo/create.go @@ -13,7 +13,6 @@ import ( "github.com/kubefirst/kubefirst-api/internal/controller" "github.com/kubefirst/kubefirst-api/internal/db" "github.com/kubefirst/kubefirst-api/internal/services" - "github.com/kubefirst/kubefirst-api/pkg/metrics" pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types" "github.com/kubefirst/metrics-client/pkg/telemetry" "github.com/kubefirst/runtime/pkg/k8s" @@ -237,7 +236,7 @@ func CreateCivoCluster(definition *pkgtypes.ClusterDefinition) error { log.Info("cluster creation complete") - telemetry.SendCountMetric(ctrl.Telemetry, metrics.ClusterInstallCompleted, "") + telemetry.SendCountMetric(ctrl.Telemetry, telemetry.ClusterInstallCompleted, "") // Create default service entries cl, _ := db.Client.GetCluster(ctrl.ClusterName) diff --git a/providers/civo/delete.go b/providers/civo/delete.go index cfae1158..de2511b3 100644 --- a/providers/civo/delete.go +++ b/providers/civo/delete.go @@ -20,7 +20,6 @@ import ( "github.com/kubefirst/kubefirst-api/internal/constants" "github.com/kubefirst/kubefirst-api/internal/db" "github.com/kubefirst/kubefirst-api/internal/errors" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/kubefirst-api/pkg/providerConfigs" pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types" "github.com/kubefirst/metrics-client/pkg/telemetry" @@ -42,7 +41,7 @@ func DeleteCivoCluster(cl *pkgtypes.Cluster, segmentClient *telemetry.SegmentCli log.SetReportCaller(false) log.SetOutput(os.Stdout) - telemetry.SendCountMetric(segmentClient, metrics.ClusterDeleteStarted, "") + telemetry.SendCountMetric(segmentClient, telemetry.ClusterDeleteStarted, "") // Instantiate civo config config := providerConfigs.GetConfig(cl.ClusterName, cl.DomainName, cl.GitProvider, cl.GitAuth.Owner, cl.GitProtocol, cl.CloudflareAuth.APIToken, cl.CloudflareAuth.OriginCaIssuerKey) @@ -250,7 +249,7 @@ func DeleteCivoCluster(cl *pkgtypes.Cluster, segmentClient *telemetry.SegmentCli } } - telemetry.SendCountMetric(segmentClient, metrics.ClusterDeleteCompleted, "") + telemetry.SendCountMetric(segmentClient, telemetry.ClusterDeleteCompleted, "") err = db.Client.UpdateCluster(cl.ClusterName, "status", constants.ClusterStatusDeleted) if err != nil { diff --git a/providers/digitalocean/create.go b/providers/digitalocean/create.go index 1fa7812c..4e5b84f8 100644 --- a/providers/digitalocean/create.go +++ b/providers/digitalocean/create.go @@ -13,7 +13,6 @@ import ( "github.com/kubefirst/kubefirst-api/internal/controller" "github.com/kubefirst/kubefirst-api/internal/db" "github.com/kubefirst/kubefirst-api/internal/services" - "github.com/kubefirst/kubefirst-api/pkg/metrics" pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types" "github.com/kubefirst/metrics-client/pkg/telemetry" "github.com/kubefirst/runtime/pkg/k8s" @@ -232,7 +231,7 @@ func CreateDigitaloceanCluster(definition *pkgtypes.ClusterDefinition) error { // Telemetry handler - telemetry.SendCountMetric(ctrl.Telemetry, metrics.ClusterInstallCompleted, "") + telemetry.SendCountMetric(ctrl.Telemetry, telemetry.ClusterInstallCompleted, "") // Create default service entries cl, _ := db.Client.GetCluster(ctrl.ClusterName) diff --git a/providers/digitalocean/delete.go b/providers/digitalocean/delete.go index 57c8176a..a0b520a0 100644 --- a/providers/digitalocean/delete.go +++ b/providers/digitalocean/delete.go @@ -20,7 +20,6 @@ import ( "github.com/kubefirst/kubefirst-api/internal/constants" "github.com/kubefirst/kubefirst-api/internal/db" "github.com/kubefirst/kubefirst-api/internal/errors" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/kubefirst-api/pkg/providerConfigs" pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types" "github.com/kubefirst/metrics-client/pkg/telemetry" @@ -43,7 +42,7 @@ func DeleteDigitaloceanCluster(cl *pkgtypes.Cluster, segmentClient *telemetry.Se log.SetReportCaller(false) log.SetOutput(os.Stdout) - telemetry.SendCountMetric(segmentClient, metrics.ClusterDeleteStarted, "") + telemetry.SendCountMetric(segmentClient, telemetry.ClusterDeleteStarted, "") // Instantiate digitalocean config config := providerConfigs.GetConfig(cl.ClusterName, cl.DomainName, cl.GitProvider, cl.GitAuth.Owner, cl.GitProtocol, cl.CloudflareAuth.Token, "") @@ -280,7 +279,7 @@ func DeleteDigitaloceanCluster(cl *pkgtypes.Cluster, segmentClient *telemetry.Se } } - telemetry.SendCountMetric(segmentClient, metrics.ClusterDeleteCompleted, "") + telemetry.SendCountMetric(segmentClient, telemetry.ClusterDeleteCompleted, "") err = db.Client.UpdateCluster(cl.ClusterName, "status", constants.ClusterStatusDeleted) if err != nil { diff --git a/providers/google/create.go b/providers/google/create.go index f822b2d0..fe742377 100644 --- a/providers/google/create.go +++ b/providers/google/create.go @@ -15,7 +15,6 @@ import ( "github.com/kubefirst/kubefirst-api/internal/db" "github.com/kubefirst/kubefirst-api/internal/services" "github.com/kubefirst/kubefirst-api/pkg/google" - "github.com/kubefirst/kubefirst-api/pkg/metrics" pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types" "github.com/kubefirst/metrics-client/pkg/telemetry" "github.com/kubefirst/runtime/pkg/k8s" @@ -254,7 +253,7 @@ func CreateGoogleCluster(definition *pkgtypes.ClusterDefinition) error { log.Info("cluster creation complete") - telemetry.SendCountMetric(ctrl.Telemetry, metrics.ClusterInstallCompleted, "") + telemetry.SendCountMetric(ctrl.Telemetry, telemetry.ClusterInstallCompleted, "") // Create default service entries cl, _ := db.Client.GetCluster(ctrl.ClusterName) diff --git a/providers/google/delete.go b/providers/google/delete.go index 3e28c3a7..5138e1b3 100644 --- a/providers/google/delete.go +++ b/providers/google/delete.go @@ -21,7 +21,6 @@ import ( "github.com/kubefirst/kubefirst-api/internal/db" "github.com/kubefirst/kubefirst-api/internal/errors" "github.com/kubefirst/kubefirst-api/pkg/google" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/kubefirst-api/pkg/providerConfigs" pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types" "github.com/kubefirst/metrics-client/pkg/telemetry" @@ -43,7 +42,7 @@ func DeleteGoogleCluster(cl *pkgtypes.Cluster, segmentClient *telemetry.SegmentC log.SetReportCaller(false) log.SetOutput(os.Stdout) - telemetry.SendCountMetric(segmentClient, metrics.ClusterDeleteStarted, "") + telemetry.SendCountMetric(segmentClient, telemetry.ClusterDeleteStarted, "") // Instantiate google config config := providerConfigs.GetConfig(cl.ClusterName, cl.DomainName, cl.GitProvider, cl.GitAuth.Owner, cl.GitProtocol, cl.CloudflareAuth.Token, "") @@ -252,7 +251,7 @@ func DeleteGoogleCluster(cl *pkgtypes.Cluster, segmentClient *telemetry.SegmentC } } - telemetry.SendCountMetric(segmentClient, metrics.ClusterDeleteCompleted, "") + telemetry.SendCountMetric(segmentClient, telemetry.ClusterDeleteCompleted, "") err = db.Client.UpdateCluster(cl.ClusterName, "status", constants.ClusterStatusDeleted) if err != nil { diff --git a/providers/vultr/create.go b/providers/vultr/create.go index 6bee4960..c51a5efe 100644 --- a/providers/vultr/create.go +++ b/providers/vultr/create.go @@ -13,7 +13,6 @@ import ( "github.com/kubefirst/kubefirst-api/internal/controller" "github.com/kubefirst/kubefirst-api/internal/db" "github.com/kubefirst/kubefirst-api/internal/services" - "github.com/kubefirst/kubefirst-api/pkg/metrics" pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types" "github.com/kubefirst/metrics-client/pkg/telemetry" "github.com/kubefirst/runtime/pkg/k8s" @@ -228,7 +227,7 @@ func CreateVultrCluster(definition *pkgtypes.ClusterDefinition) error { log.Info("cluster creation complete") - telemetry.SendCountMetric(ctrl.Telemetry, metrics.ClusterInstallCompleted, "") + telemetry.SendCountMetric(ctrl.Telemetry, telemetry.ClusterInstallCompleted, "") // Create default service entries cl, _ := db.Client.GetCluster(ctrl.ClusterName) diff --git a/providers/vultr/delete.go b/providers/vultr/delete.go index 2fefb50b..700b4f54 100644 --- a/providers/vultr/delete.go +++ b/providers/vultr/delete.go @@ -20,7 +20,6 @@ import ( "github.com/kubefirst/kubefirst-api/internal/constants" "github.com/kubefirst/kubefirst-api/internal/db" "github.com/kubefirst/kubefirst-api/internal/errors" - "github.com/kubefirst/kubefirst-api/pkg/metrics" "github.com/kubefirst/kubefirst-api/pkg/providerConfigs" pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types" "github.com/kubefirst/metrics-client/pkg/telemetry" @@ -43,7 +42,7 @@ func DeleteVultrCluster(cl *pkgtypes.Cluster, segmentClient *telemetry.SegmentCl log.SetReportCaller(false) log.SetOutput(os.Stdout) - telemetry.SendCountMetric(segmentClient, metrics.ClusterDeleteStarted, "") + telemetry.SendCountMetric(segmentClient, telemetry.ClusterDeleteStarted, "") // Instantiate vultr config config := providerConfigs.GetConfig(cl.ClusterName, cl.DomainName, cl.GitProvider, cl.GitAuth.Owner, cl.GitProtocol, cl.CloudflareAuth.Token, "") @@ -280,7 +279,7 @@ func DeleteVultrCluster(cl *pkgtypes.Cluster, segmentClient *telemetry.SegmentCl } } - telemetry.SendCountMetric(segmentClient, metrics.ClusterDeleteCompleted, "") + telemetry.SendCountMetric(segmentClient, telemetry.ClusterDeleteCompleted, "") err = db.Client.UpdateCluster(cl.ClusterName, "status", constants.ClusterStatusDeleted) if err != nil {