Skip to content

Commit

Permalink
feat: update metrics lib to track os, arch & backend type (#11)
Browse files Browse the repository at this point in the history
* update metrics lib & added backend

* fix circular dependency

* update error message

* removed else condition

* deleted empty space
  • Loading branch information
h4ck3rk3y committed Feb 16, 2023
1 parent 1c5adb5 commit 15cf9bb
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cli/cli/go.mod
Expand Up @@ -20,7 +20,7 @@ require (
github.com/kurtosis-tech/kurtosis/container-engine-lib v0.0.0 // local dependency
github.com/kurtosis-tech/kurtosis/engine/launcher v0.0.0 // local dependency
github.com/kurtosis-tech/kurtosis/kurtosis_version v0.0.0 // Local dependency generated during build
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230214135833-e362c2ee8600
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230215143841-da53ad89218e
github.com/kurtosis-tech/stacktrace v0.0.0-20211028211901-1c67a77b5409
github.com/manifoldco/promptui v0.9.0
github.com/mattn/go-isatty v0.0.14
Expand Down
4 changes: 2 additions & 2 deletions cli/cli/go.sum
Expand Up @@ -291,10 +291,10 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kurtosis-tech/free-ip-addr-tracker-lib v0.0.0-20211106222342-1f73d028840d h1:IWFwJfg2EhA/9Anv+VyG3LSTEZ/TZL30tUaVCFrzWK0=
github.com/kurtosis-tech/free-ip-addr-tracker-lib v0.0.0-20211106222342-1f73d028840d/go.mod h1:1PoW/0l4K80JRSj7A13aONsnaTdTM+dM36DIfDbYmVs=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230214135635-c0b9b4c3852b h1:9toVF4LTX6bfMlGIiD9Yh0+o7gDYb58ko0Bwxtw6yLM=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230214135635-c0b9b4c3852b/go.mod h1:tteWV+M47xMHxqCIPQmdmgPW80rhN8YfzrgRRWbQhOw=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230214135833-e362c2ee8600 h1:8GZVRAr16u7WCy/5xNsjZIgEcslh02cHCa3AzBSa7ME=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230214135833-e362c2ee8600/go.mod h1:tteWV+M47xMHxqCIPQmdmgPW80rhN8YfzrgRRWbQhOw=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230215143841-da53ad89218e h1:VSoT53oeS53dGr28LtVVbwihdcRHQShsufbQjyHm/5M=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230215143841-da53ad89218e/go.mod h1:tteWV+M47xMHxqCIPQmdmgPW80rhN8YfzrgRRWbQhOw=
github.com/kurtosis-tech/stacktrace v0.0.0-20211028211901-1c67a77b5409 h1:YQTATifMUwZEtZYb0LVA7DK2pj8s71iY8rzweuUQ5+g=
github.com/kurtosis-tech/stacktrace v0.0.0-20211028211901-1c67a77b5409/go.mod h1:y5weVs5d9wXXHcDA1awRxkIhhHC1xxYJN8a7aXnE6S8=
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
Expand Down
Expand Up @@ -3,6 +3,8 @@ package user_send_metrics_election
import (
"github.com/kurtosis-tech/kurtosis/cli/cli/helpers/metrics_user_id_store"
"github.com/kurtosis-tech/kurtosis/cli/cli/helpers/user_send_metrics_election/user_metrics_election_event_backlog"
"github.com/kurtosis-tech/kurtosis/cli/cli/kurtosis_cluster_setting"
"github.com/kurtosis-tech/kurtosis/cli/cli/kurtosis_config/resolved_config"
"github.com/kurtosis-tech/kurtosis/kurtosis_version"
metrics_client "github.com/kurtosis-tech/metrics-library/golang/lib/client"
"github.com/kurtosis-tech/metrics-library/golang/lib/source"
Expand All @@ -23,6 +25,21 @@ func SendAnyBackloggedUserMetricsElectionEvent() error {
return stacktrace.Propagate(err, "An error occurred checking if a user-consent-to-send-metrics-election backlog exists")
}

clusterSettingStore := kurtosis_cluster_setting.GetKurtosisClusterSettingStore()

isClusterSet, err := clusterSettingStore.HasClusterSetting()
if err != nil {
return stacktrace.Propagate(err, "Failed to check if cluster setting has been set.")
}

clusterType := resolved_config.DefaultDockerClusterName
if isClusterSet {
clusterType, err = clusterSettingStore.GetClusterSetting()
if err != nil {
return stacktrace.Propagate(err, "Cluster is set but config couldn't be fetched")
}
}

if hasBackloggedEvent {
metricsUserIdStore := metrics_user_id_store.GetMetricsUserIDStore()

Expand All @@ -38,6 +55,7 @@ func SendAnyBackloggedUserMetricsElectionEvent() error {
source.KurtosisCLISource,
kurtosis_version.KurtosisVersion,
metricsUserId,
clusterType,
didUserAcceptSendingMetricsValueForMetricsClientCreation,
shouldFlushMetricsClientQueueOnEachEvent,
metricsClientCallback,
Expand Down
1 change: 1 addition & 0 deletions core/server/api_container/main.go
Expand Up @@ -183,6 +183,7 @@ func runMain() error {
source.KurtosisCoreSource,
serverArgs.Version,
serverArgs.MetricsUserID,
serverArgs.KurtosisBackendType.String(),
serverArgs.DidUserAcceptSendingMetrics,
shouldFlushMetricsClientQueueOnEachEvent,
doNothingMetricsClientCallback{},
Expand Down
2 changes: 1 addition & 1 deletion core/server/go.mod
Expand Up @@ -29,7 +29,7 @@ require (
github.com/cenkalti/backoff/v4 v4.2.0
github.com/go-git/go-git/v5 v5.4.2
github.com/itchyny/gojq v0.12.9
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230214135833-e362c2ee8600
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230215143841-da53ad89218e
github.com/mholt/archiver v3.1.1+incompatible
github.com/pkg/errors v0.9.1
go.etcd.io/bbolt v1.3.6
Expand Down
4 changes: 2 additions & 2 deletions core/server/go.sum
Expand Up @@ -139,10 +139,10 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kurtosis-tech/free-ip-addr-tracker-lib v0.0.0-20211106222342-d3be9e82993e h1:CDNMjCNCvvCPSpoakxYZ3IHjBsxo9rLiMyjgvPYL87Q=
github.com/kurtosis-tech/free-ip-addr-tracker-lib v0.0.0-20211106222342-d3be9e82993e/go.mod h1:1PoW/0l4K80JRSj7A13aONsnaTdTM+dM36DIfDbYmVs=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230214135635-c0b9b4c3852b h1:9toVF4LTX6bfMlGIiD9Yh0+o7gDYb58ko0Bwxtw6yLM=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230214135635-c0b9b4c3852b/go.mod h1:tteWV+M47xMHxqCIPQmdmgPW80rhN8YfzrgRRWbQhOw=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230214135833-e362c2ee8600 h1:8GZVRAr16u7WCy/5xNsjZIgEcslh02cHCa3AzBSa7ME=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230214135833-e362c2ee8600/go.mod h1:tteWV+M47xMHxqCIPQmdmgPW80rhN8YfzrgRRWbQhOw=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230215143841-da53ad89218e h1:VSoT53oeS53dGr28LtVVbwihdcRHQShsufbQjyHm/5M=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230215143841-da53ad89218e/go.mod h1:tteWV+M47xMHxqCIPQmdmgPW80rhN8YfzrgRRWbQhOw=
github.com/kurtosis-tech/minimal-grpc-server/golang v0.0.0-20211201000847-a204edc5a0b3 h1:Begoh17x/9rLWQLM64A8oINjoQk1DFKN2iwhQf1i0Rc=
github.com/kurtosis-tech/minimal-grpc-server/golang v0.0.0-20211201000847-a204edc5a0b3/go.mod h1:Y0O+lt256iWpkdjDOB8r6csF96Pt3JVIFMbUuWIvr8o=
github.com/kurtosis-tech/stacktrace v0.0.0-20211028211901-1c67a77b5409 h1:YQTATifMUwZEtZYb0LVA7DK2pj8s71iY8rzweuUQ5+g=
Expand Down
1 change: 1 addition & 0 deletions engine/server/engine/main.go
Expand Up @@ -125,6 +125,7 @@ func runMain() error {
source.KurtosisEngineSource,
serverArgs.ImageVersionTag,
serverArgs.MetricsUserID,
serverArgs.KurtosisBackendType.String(),
serverArgs.DidUserAcceptSendingMetrics,
shouldFlushMetricsClientQueueOnEachEvent,
doNothingMetricsClientCallback{},
Expand Down
2 changes: 1 addition & 1 deletion engine/server/go.mod
Expand Up @@ -15,7 +15,7 @@ require (
github.com/kurtosis-tech/kurtosis/container-engine-lib v0.0.0 // local dependency
github.com/kurtosis-tech/kurtosis/core/launcher v0.0.0 // local dependency
github.com/kurtosis-tech/kurtosis/engine/launcher v0.0.0
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230214135833-e362c2ee8600
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230215143841-da53ad89218e
github.com/kurtosis-tech/minimal-grpc-server/golang v0.0.0-20211201000847-a204edc5a0b3
github.com/kurtosis-tech/stacktrace v0.0.0-20211028211901-1c67a77b5409
github.com/sirupsen/logrus v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions engine/server/go.sum
Expand Up @@ -100,10 +100,10 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kurtosis-tech/free-ip-addr-tracker-lib v0.0.0-20211106222342-1f73d028840d h1:IWFwJfg2EhA/9Anv+VyG3LSTEZ/TZL30tUaVCFrzWK0=
github.com/kurtosis-tech/free-ip-addr-tracker-lib v0.0.0-20211106222342-1f73d028840d/go.mod h1:1PoW/0l4K80JRSj7A13aONsnaTdTM+dM36DIfDbYmVs=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230214135635-c0b9b4c3852b h1:9toVF4LTX6bfMlGIiD9Yh0+o7gDYb58ko0Bwxtw6yLM=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230214135635-c0b9b4c3852b/go.mod h1:tteWV+M47xMHxqCIPQmdmgPW80rhN8YfzrgRRWbQhOw=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230214135833-e362c2ee8600 h1:8GZVRAr16u7WCy/5xNsjZIgEcslh02cHCa3AzBSa7ME=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230214135833-e362c2ee8600/go.mod h1:tteWV+M47xMHxqCIPQmdmgPW80rhN8YfzrgRRWbQhOw=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230215143841-da53ad89218e h1:VSoT53oeS53dGr28LtVVbwihdcRHQShsufbQjyHm/5M=
github.com/kurtosis-tech/metrics-library/golang v0.0.0-20230215143841-da53ad89218e/go.mod h1:tteWV+M47xMHxqCIPQmdmgPW80rhN8YfzrgRRWbQhOw=
github.com/kurtosis-tech/minimal-grpc-server/golang v0.0.0-20211201000847-a204edc5a0b3 h1:Begoh17x/9rLWQLM64A8oINjoQk1DFKN2iwhQf1i0Rc=
github.com/kurtosis-tech/minimal-grpc-server/golang v0.0.0-20211201000847-a204edc5a0b3/go.mod h1:Y0O+lt256iWpkdjDOB8r6csF96Pt3JVIFMbUuWIvr8o=
github.com/kurtosis-tech/stacktrace v0.0.0-20211028211901-1c67a77b5409 h1:YQTATifMUwZEtZYb0LVA7DK2pj8s71iY8rzweuUQ5+g=
Expand Down

0 comments on commit 15cf9bb

Please sign in to comment.