diff --git a/.golangci.yml b/.golangci.yml index 22e8b34ba8..81eb0fd788 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -21,7 +21,9 @@ linters-settings: - pkg: "github.com/percona/go-mysql/log/slow" desc: only use the forked parser - pkg: "github.com/percona-platform/platform" - desc: use "github.com/percona-platform/saas" instead + desc: use "github.com/percona/saas" instead + - pkg: "github.com/percona/platform" + desc: use "github.com/percona/saas" instead - pkg: "gopkg.in/yaml.v2" desc: use "gopkg.in/yaml.v3" instead diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0b9c1aca54..1920ed3c99 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,7 +18,7 @@ This project is built from several repositories: ### APIs * [percona/pmm](https://github.com/percona/pmm/tree/main/api) -* [percona-platform/saas](https://github.com/percona-platform/saas) +* [percona/saas](https://github.com/percona/saas) ### PMM Server diff --git a/api-tests/alerting/alerting_test.go b/api-tests/alerting/alerting_test.go index 3eccff32a5..504e5425ac 100644 --- a/api-tests/alerting/alerting_test.go +++ b/api-tests/alerting/alerting_test.go @@ -31,7 +31,7 @@ import ( "github.com/AlekSi/pointer" "github.com/google/uuid" gapi "github.com/grafana/grafana-api-golang-client" - "github.com/percona-platform/saas/pkg/alert" + "github.com/percona/saas/pkg/alert" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" diff --git a/go.mod b/go.mod index 3c4a60cf81..fb1c6deb96 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/percona/pmm go 1.23.2 // Update saas with -// go get -v github.com/percona-platform/saas@latest +// go get -v github.com/percona/saas@latest replace github.com/grpc-ecosystem/go-grpc-prometheus => github.com/Percona-Lab/go-grpc-prometheus v0.0.0-20230116133345-3487748d4592 @@ -51,11 +51,11 @@ require ( github.com/jotaen/kong-completion v0.0.5 github.com/lib/pq v1.10.9 github.com/minio/minio-go/v7 v7.0.55 - github.com/percona-platform/saas v0.0.0-20230728161159-ad6bdeb8a3d9 github.com/percona/exporter_shared v0.7.5 github.com/percona/go-mysql v0.0.0-20210427141028-73d29c6da78c github.com/percona/percona-toolkit v3.2.1+incompatible github.com/percona/promconfig v0.2.5 + github.com/percona/saas v0.0.0-20240923141535-da19f6682c6e github.com/pganalyze/pg_query_go/v5 v5.1.0 github.com/pkg/errors v0.9.1 github.com/pkg/sftp v1.13.6 diff --git a/go.sum b/go.sum index 566408577f..b4c651fbfe 100644 --- a/go.sum +++ b/go.sum @@ -410,8 +410,6 @@ github.com/paulmach/orb v0.11.1/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/En github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY= github.com/percona-lab/crypto v0.0.0-20231108144114-756dfb24eaf2 h1:FaO5loTAkRzVhyKWYRHg/ii9oWXNsqv89H/kGl9Cb5I= github.com/percona-lab/crypto v0.0.0-20231108144114-756dfb24eaf2/go.mod h1:aSyBXtGhRzSMdne9jbl3+PPMVS0IgOWF6Llc+HB5uUU= -github.com/percona-platform/saas v0.0.0-20230728161159-ad6bdeb8a3d9 h1:KkOH+Y4sVRP7qvRtTDmfPFNjjQcwU2054/jNl9DZhEo= -github.com/percona-platform/saas v0.0.0-20230728161159-ad6bdeb8a3d9/go.mod h1:lZuFcqj0EoQWx28SYkTcdhJOCQEbRcAyahYPfRMY7tc= github.com/percona/exporter_shared v0.7.5 h1:sIhdDtKOfH0jsqtTAi41C7wm1R42yXYeAkK0QWhgN7k= github.com/percona/exporter_shared v0.7.5/go.mod h1:P8ZHDzveyJRGD4ZIRNiEMuAdDexBpQWf2mAVwtyVcYU= github.com/percona/go-mysql v0.0.0-20210427141028-73d29c6da78c h1:1SZ7nS+kSaO63IpaKspf/gf8602QcgP2eXNPMNOIc0M= @@ -420,6 +418,8 @@ github.com/percona/percona-toolkit v3.2.1+incompatible h1:5jLvtZKcu9fDmaLRB8qA4b github.com/percona/percona-toolkit v3.2.1+incompatible/go.mod h1:netQWdWMaF1cnmwiIS+i5uyaqNXz46yNeM6HKkR6yeI= github.com/percona/promconfig v0.2.5 h1:f/HN/CbECQs7d9RIB6MKVkuXstsrsqEDxRvf6yigquc= github.com/percona/promconfig v0.2.5/go.mod h1:Y2uXi5QNk71+ceJHuI9poank+0S1kjxd3K105fXKVkg= +github.com/percona/saas v0.0.0-20240923141535-da19f6682c6e h1:xhk5ivxlTPat0SwLBqU1UdfqJb+2R3x4yAhjCf6WMEU= +github.com/percona/saas v0.0.0-20240923141535-da19f6682c6e/go.mod h1:UP4WqGWy8xeGhEoDFaB1aPNNtNs/TYXQ8MjUrN6rXis= github.com/pganalyze/pg_query_go/v5 v5.1.0 h1:MlxQqHZnvA3cbRQYyIrjxEjzo560P6MyTgtlaf3pmXg= github.com/pganalyze/pg_query_go/v5 v5.1.0/go.mod h1:FsglvxidZsVN+Ltw3Ai6nTgPVcK2BPukH3jCDEqc1Ug= github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ= diff --git a/managed/cmd/pmm-managed-starlark/main.go b/managed/cmd/pmm-managed-starlark/main.go index 3e89d4463f..71d891a0cd 100644 --- a/managed/cmd/pmm-managed-starlark/main.go +++ b/managed/cmd/pmm-managed-starlark/main.go @@ -24,8 +24,8 @@ import ( "time" "github.com/alecthomas/kingpin/v2" - "github.com/percona-platform/saas/pkg/check" - "github.com/percona-platform/saas/pkg/starlark" + "github.com/percona/saas/pkg/check" + "github.com/percona/saas/pkg/starlark" "github.com/pkg/errors" "github.com/sirupsen/logrus" "go.starlark.net/resolve" diff --git a/managed/cmd/pmm-managed-starlark/main_test.go b/managed/cmd/pmm-managed-starlark/main_test.go index 6053b8615a..ec9eedb3d3 100644 --- a/managed/cmd/pmm-managed-starlark/main_test.go +++ b/managed/cmd/pmm-managed-starlark/main_test.go @@ -24,7 +24,7 @@ import ( "testing" "time" - "github.com/percona-platform/saas/pkg/check" + "github.com/percona/saas/pkg/check" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/managed/models/template_helpers.go b/managed/models/template_helpers.go index 071db6e7e9..2dbe7dd1f3 100644 --- a/managed/models/template_helpers.go +++ b/managed/models/template_helpers.go @@ -19,7 +19,7 @@ import ( "time" "github.com/AlekSi/pointer" - "github.com/percona-platform/saas/pkg/alert" + "github.com/percona/saas/pkg/alert" "github.com/pkg/errors" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/managed/models/template_helpers_test.go b/managed/models/template_helpers_test.go index 4394cf8cce..35d6b8b7a1 100644 --- a/managed/models/template_helpers_test.go +++ b/managed/models/template_helpers_test.go @@ -22,9 +22,9 @@ import ( "github.com/AlekSi/pointer" "github.com/brianvoe/gofakeit/v6" "github.com/google/uuid" - "github.com/percona-platform/saas/pkg/alert" - "github.com/percona-platform/saas/pkg/common" "github.com/percona/promconfig" + "github.com/percona/saas/pkg/alert" + "github.com/percona/saas/pkg/common" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gopkg.in/reform.v1" diff --git a/managed/models/template_model.go b/managed/models/template_model.go index fc1794f6a5..e0823a0563 100644 --- a/managed/models/template_model.go +++ b/managed/models/template_model.go @@ -19,7 +19,7 @@ import ( "database/sql/driver" "time" - "github.com/percona-platform/saas/pkg/common" + "github.com/percona/saas/pkg/common" "github.com/pkg/errors" "gopkg.in/reform.v1" ) diff --git a/managed/services/alerting/service.go b/managed/services/alerting/service.go index 4214b4847b..46cdd27709 100644 --- a/managed/services/alerting/service.go +++ b/managed/services/alerting/service.go @@ -30,8 +30,8 @@ import ( "time" "github.com/AlekSi/pointer" - "github.com/percona-platform/saas/pkg/alert" - "github.com/percona-platform/saas/pkg/common" + "github.com/percona/saas/pkg/alert" + "github.com/percona/saas/pkg/common" "github.com/pkg/errors" "github.com/sirupsen/logrus" "google.golang.org/grpc/codes" diff --git a/managed/services/checks/checks.go b/managed/services/checks/checks.go index 0f91051422..3144a2e07f 100644 --- a/managed/services/checks/checks.go +++ b/managed/services/checks/checks.go @@ -32,7 +32,7 @@ import ( "text/template" "time" - "github.com/percona-platform/saas/pkg/check" + "github.com/percona/saas/pkg/check" "github.com/pkg/errors" v1 "github.com/prometheus/client_golang/api/prometheus/v1" prom "github.com/prometheus/client_golang/prometheus" diff --git a/managed/services/checks/checks_test.go b/managed/services/checks/checks_test.go index 50b0a76611..8a81e503fd 100644 --- a/managed/services/checks/checks_test.go +++ b/managed/services/checks/checks_test.go @@ -24,8 +24,8 @@ import ( "github.com/AlekSi/pointer" _ "github.com/ClickHouse/clickhouse-go/v2" - "github.com/percona-platform/saas/pkg/check" - "github.com/percona-platform/saas/pkg/common" + "github.com/percona/saas/pkg/check" + "github.com/percona/saas/pkg/common" metrics "github.com/prometheus/client_golang/api" v1 "github.com/prometheus/client_golang/api/prometheus/v1" "github.com/sirupsen/logrus" diff --git a/managed/services/checks/funcs.go b/managed/services/checks/funcs.go index aa046777d5..df82b95adf 100644 --- a/managed/services/checks/funcs.go +++ b/managed/services/checks/funcs.go @@ -19,7 +19,7 @@ import ( "net" "strconv" - "github.com/percona-platform/saas/pkg/starlark" + "github.com/percona/saas/pkg/starlark" "github.com/pkg/errors" "github.com/sirupsen/logrus" diff --git a/managed/services/checks/funcs_test.go b/managed/services/checks/funcs_test.go index 2723d4e8c8..58797088df 100644 --- a/managed/services/checks/funcs_test.go +++ b/managed/services/checks/funcs_test.go @@ -19,9 +19,9 @@ import ( "strings" "testing" - "github.com/percona-platform/saas/pkg/check" - "github.com/percona-platform/saas/pkg/common" - "github.com/percona-platform/saas/pkg/starlark" + "github.com/percona/saas/pkg/check" + "github.com/percona/saas/pkg/common" + "github.com/percona/saas/pkg/starlark" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/managed/services/checks/registry.go b/managed/services/checks/registry.go index 2b51279eb6..5c95502239 100644 --- a/managed/services/checks/registry.go +++ b/managed/services/checks/registry.go @@ -18,7 +18,7 @@ package checks import ( "sync" - "github.com/percona-platform/saas/pkg/check" + "github.com/percona/saas/pkg/check" prom "github.com/prometheus/client_golang/prometheus" "github.com/percona/pmm/managed/services" diff --git a/managed/services/checks/registry_test.go b/managed/services/checks/registry_test.go index 47bc4c8ab5..00a800042c 100644 --- a/managed/services/checks/registry_test.go +++ b/managed/services/checks/registry_test.go @@ -18,8 +18,8 @@ package checks import ( "testing" - "github.com/percona-platform/saas/pkg/check" - "github.com/percona-platform/saas/pkg/common" + "github.com/percona/saas/pkg/check" + "github.com/percona/saas/pkg/common" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/managed/services/management/checks.go b/managed/services/management/checks.go index bb3d69de0b..42511d6693 100644 --- a/managed/services/management/checks.go +++ b/managed/services/management/checks.go @@ -20,8 +20,8 @@ import ( "strings" "github.com/AlekSi/pointer" - "github.com/percona-platform/saas/pkg/check" - "github.com/percona-platform/saas/pkg/common" + "github.com/percona/saas/pkg/check" + "github.com/percona/saas/pkg/common" "github.com/pkg/errors" "github.com/sirupsen/logrus" "google.golang.org/grpc/codes" diff --git a/managed/services/management/checks_test.go b/managed/services/management/checks_test.go index 4d24997740..c7a3b78cb8 100644 --- a/managed/services/management/checks_test.go +++ b/managed/services/management/checks_test.go @@ -21,8 +21,8 @@ import ( "testing" "github.com/AlekSi/pointer" - "github.com/percona-platform/saas/pkg/check" - "github.com/percona-platform/saas/pkg/common" + "github.com/percona/saas/pkg/check" + "github.com/percona/saas/pkg/common" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/managed/services/management/deps.go b/managed/services/management/deps.go index dee58d918b..db929a452c 100644 --- a/managed/services/management/deps.go +++ b/managed/services/management/deps.go @@ -19,7 +19,7 @@ import ( "context" "time" - "github.com/percona-platform/saas/pkg/check" + "github.com/percona/saas/pkg/check" v1 "github.com/prometheus/client_golang/api/prometheus/v1" "github.com/prometheus/common/model" "gopkg.in/reform.v1" diff --git a/managed/services/management/mock_checks_service_test.go b/managed/services/management/mock_checks_service_test.go index 7ea9954892..b0bd6a7b49 100644 --- a/managed/services/management/mock_checks_service_test.go +++ b/managed/services/management/mock_checks_service_test.go @@ -5,7 +5,7 @@ package management import ( context "context" - check "github.com/percona-platform/saas/pkg/check" + check "github.com/percona/saas/pkg/check" mock "github.com/stretchr/testify/mock" services "github.com/percona/pmm/managed/services" diff --git a/managed/services/telemetry/datasource_envvars.go b/managed/services/telemetry/datasource_envvars.go index 4dc320a51c..0e2fe89a24 100644 --- a/managed/services/telemetry/datasource_envvars.go +++ b/managed/services/telemetry/datasource_envvars.go @@ -20,7 +20,7 @@ import ( "context" "os" - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" + telemetryv1 "github.com/percona/saas/gen/telemetry/generic" "github.com/sirupsen/logrus" ) @@ -51,8 +51,8 @@ func (d *dsEnvvars) Init(_ context.Context) error { return nil } -func (d *dsEnvvars) FetchMetrics(_ context.Context, config Config) ([]*pmmv1.ServerMetric_Metric, error) { - var metrics []*pmmv1.ServerMetric_Metric +func (d *dsEnvvars) FetchMetrics(_ context.Context, config Config) ([]*telemetryv1.GenericReport_Metric, error) { + var metrics []*telemetryv1.GenericReport_Metric check := make(map[string]bool, len(config.Data)) @@ -69,7 +69,7 @@ func (d *dsEnvvars) FetchMetrics(_ context.Context, config Config) ([]*pmmv1.Ser check[col.MetricName] = true - metrics = append(metrics, &pmmv1.ServerMetric_Metric{ + metrics = append(metrics, &telemetryv1.GenericReport_Metric{ Key: col.MetricName, Value: value, }) diff --git a/managed/services/telemetry/datasource_envvars_test.go b/managed/services/telemetry/datasource_envvars_test.go index 5139d68c48..8bd152eb09 100644 --- a/managed/services/telemetry/datasource_envvars_test.go +++ b/managed/services/telemetry/datasource_envvars_test.go @@ -21,7 +21,7 @@ import ( "os" "testing" - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" + telemetryv1 "github.com/percona/saas/gen/telemetry/generic" "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -94,7 +94,7 @@ func TestEnvVarsDatasource(t *testing.T) { metrics, err := dsEnvVars.FetchMetrics(ctx, *config) require.NoError(t, err) - expected := []*pmmv1.ServerMetric_Metric{ + expected := []*telemetryv1.GenericReport_Metric{ {Key: "test_env_var1", Value: "1"}, {Key: "test_env_var2", Value: "test"}, {Key: "test_env_var3", Value: "true"}, @@ -138,7 +138,7 @@ func TestEnvVarsDatasource(t *testing.T) { metrics, err := dsEnvVars.FetchMetrics(ctx, *config) require.NoError(t, err) - expected := []*pmmv1.ServerMetric_Metric{ + expected := []*telemetryv1.GenericReport_Metric{ {Key: "test_env_var6", Value: "1"}, {Key: "test_env_var7", Value: "1"}, {Key: "test_env_var8", Value: "1"}, diff --git a/managed/services/telemetry/datasource_grafanadb_select.go b/managed/services/telemetry/datasource_grafanadb_select.go index 172f9acc7c..2e46b02ca7 100644 --- a/managed/services/telemetry/datasource_grafanadb_select.go +++ b/managed/services/telemetry/datasource_grafanadb_select.go @@ -22,8 +22,7 @@ import ( "net/url" "time" - // Events, errors and driver for grafana database. - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" + telemetryv1 "github.com/percona/saas/gen/telemetry/generic" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -95,7 +94,7 @@ func openGrafanaDBConnection(config DSConfigGrafanaDB, l *logrus.Entry) (*sql.DB return db, nil } -func (d *dsGrafanaDBSelect) FetchMetrics(ctx context.Context, config Config) ([]*pmmv1.ServerMetric_Metric, error) { +func (d *dsGrafanaDBSelect) FetchMetrics(ctx context.Context, config Config) ([]*telemetryv1.GenericReport_Metric, error) { return fetchMetricsFromDB(ctx, d.l, d.config.Timeout, d.db, config) } diff --git a/managed/services/telemetry/datasource_pmmdb_select.go b/managed/services/telemetry/datasource_pmmdb_select.go index bc230cb2b9..0a5276b383 100644 --- a/managed/services/telemetry/datasource_pmmdb_select.go +++ b/managed/services/telemetry/datasource_pmmdb_select.go @@ -22,7 +22,7 @@ import ( "net/url" "time" - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" + telemetryv1 "github.com/percona/saas/gen/telemetry/generic" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -94,7 +94,7 @@ func openPMMDBConnection(config DSConfigPMMDB, l *logrus.Entry) (*sql.DB, error) return db, nil } -func (d *dsPmmDBSelect) FetchMetrics(ctx context.Context, config Config) ([]*pmmv1.ServerMetric_Metric, error) { +func (d *dsPmmDBSelect) FetchMetrics(ctx context.Context, config Config) ([]*telemetryv1.GenericReport_Metric, error) { return fetchMetricsFromDB(ctx, d.l, d.config.Timeout, d.db, config) } diff --git a/managed/services/telemetry/datasource_qandb_select.go b/managed/services/telemetry/datasource_qandb_select.go index 17e20e583c..94fff62d31 100644 --- a/managed/services/telemetry/datasource_qandb_select.go +++ b/managed/services/telemetry/datasource_qandb_select.go @@ -20,7 +20,7 @@ import ( "context" "database/sql" - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" + telemetryv1 "github.com/percona/saas/gen/telemetry/generic" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -69,7 +69,7 @@ func openQANDBConnection(dsn string, enabled bool, l *logrus.Entry) (*sql.DB, er return db, nil } -func (d *dsQanDBSelect) FetchMetrics(ctx context.Context, config Config) ([]*pmmv1.ServerMetric_Metric, error) { +func (d *dsQanDBSelect) FetchMetrics(ctx context.Context, config Config) ([]*telemetryv1.GenericReport_Metric, error) { return fetchMetricsFromDB(ctx, d.l, d.config.Timeout, d.db, config) } diff --git a/managed/services/telemetry/datasource_victoria_metrics.go b/managed/services/telemetry/datasource_victoria_metrics.go index 91d8b77659..8a8efd3b89 100644 --- a/managed/services/telemetry/datasource_victoria_metrics.go +++ b/managed/services/telemetry/datasource_victoria_metrics.go @@ -20,7 +20,7 @@ import ( "context" "time" - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" + telemetryv1 "github.com/percona/saas/gen/telemetry/generic" "github.com/prometheus/client_golang/api" v1 "github.com/prometheus/client_golang/api/prometheus/v1" "github.com/prometheus/common/model" @@ -66,7 +66,7 @@ func NewDataSourceVictoriaMetrics(config DSConfigVM, l *logrus.Entry) (DataSourc }, nil } -func (d *dataSourceVictoriaMetrics) FetchMetrics(ctx context.Context, config Config) ([]*pmmv1.ServerMetric_Metric, error) { +func (d *dataSourceVictoriaMetrics) FetchMetrics(ctx context.Context, config Config) ([]*telemetryv1.GenericReport_Metric, error) { localCtx, cancel := context.WithTimeout(ctx, d.config.Timeout) defer cancel() @@ -75,20 +75,20 @@ func (d *dataSourceVictoriaMetrics) FetchMetrics(ctx context.Context, config Con return nil, err } - var metrics []*pmmv1.ServerMetric_Metric + var metrics []*telemetryv1.GenericReport_Metric for _, v := range result.(model.Vector) { //nolint:forcetypeassert for _, configItem := range config.Data { if configItem.Label != "" { value := v.Metric[model.LabelName(configItem.Label)] - metrics = append(metrics, &pmmv1.ServerMetric_Metric{ + metrics = append(metrics, &telemetryv1.GenericReport_Metric{ Key: configItem.MetricName, Value: string(value), }) } if configItem.Value != "" { - metrics = append(metrics, &pmmv1.ServerMetric_Metric{ + metrics = append(metrics, &telemetryv1.GenericReport_Metric{ Key: configItem.MetricName, Value: v.Value.String(), }) diff --git a/managed/services/telemetry/datasources.go b/managed/services/telemetry/datasources.go index b239b55bff..0529fb2ebe 100644 --- a/managed/services/telemetry/datasources.go +++ b/managed/services/telemetry/datasources.go @@ -22,7 +22,7 @@ import ( "time" "github.com/AlekSi/pointer" - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" + telemetryv1 "github.com/percona/saas/gen/telemetry/generic" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -77,7 +77,7 @@ func (r *dataSourceRegistry) LocateTelemetryDataSource(name string) (DataSource, return ds, nil } -func fetchMetricsFromDB(ctx context.Context, l *logrus.Entry, timeout time.Duration, db *sql.DB, config Config) ([]*pmmv1.ServerMetric_Metric, error) { +func fetchMetricsFromDB(ctx context.Context, l *logrus.Entry, timeout time.Duration, db *sql.DB, config Config) ([]*telemetryv1.GenericReport_Metric, error) { localCtx, cancel := context.WithTimeout(ctx, timeout) defer cancel() tx, err := db.BeginTx(localCtx, &sql.TxOptions{}) @@ -104,7 +104,7 @@ func fetchMetricsFromDB(ctx context.Context, l *logrus.Entry, timeout time.Durat } cfgColumns := config.mapByColumn() - var metrics []*pmmv1.ServerMetric_Metric + var metrics []*telemetryv1.GenericReport_Metric for rows.Next() { if err := rows.Scan(values...); err != nil { l.Error(err) @@ -116,7 +116,7 @@ func fetchMetricsFromDB(ctx context.Context, l *logrus.Entry, timeout time.Durat if cols, ok := cfgColumns[column]; ok { for _, col := range cols { - metrics = append(metrics, &pmmv1.ServerMetric_Metric{ + metrics = append(metrics, &telemetryv1.GenericReport_Metric{ Key: col.MetricName, Value: value, }) diff --git a/managed/services/telemetry/deps.go b/managed/services/telemetry/deps.go index 603e669505..8e97ec58fa 100644 --- a/managed/services/telemetry/deps.go +++ b/managed/services/telemetry/deps.go @@ -18,8 +18,8 @@ package telemetry import ( "context" - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" - reporter "github.com/percona-platform/saas/gen/telemetry/reporter" + pmmv1 "github.com/percona/saas/gen/telemetry/events/pmm" + telemetryv1 "github.com/percona/saas/gen/telemetry/generic" serverv1 "github.com/percona/pmm/api/server/v1" ) @@ -31,7 +31,7 @@ type distributionUtilService interface { // sender is interface which defines method for client which sends report with metrics. type sender interface { - SendTelemetry(ctx context.Context, report *reporter.ReportRequest) error + SendTelemetry(ctx context.Context, report *telemetryv1.ReportRequest) error } // DataSourceLocator locates data source by name. @@ -42,7 +42,7 @@ type DataSourceLocator interface { // DataSource telemetry data source. type DataSource interface { Init(ctx context.Context) error - FetchMetrics(ctx context.Context, config Config) ([]*pmmv1.ServerMetric_Metric, error) + FetchMetrics(ctx context.Context, config Config) ([]*telemetryv1.GenericReport_Metric, error) Dispose(ctx context.Context) error Enabled() bool } diff --git a/managed/services/telemetry/extension.go b/managed/services/telemetry/extension.go index 7679b41b42..ebe4e40c9f 100644 --- a/managed/services/telemetry/extension.go +++ b/managed/services/telemetry/extension.go @@ -18,10 +18,10 @@ package telemetry import ( "context" - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" + telemetryv1 "github.com/percona/saas/gen/telemetry/generic" ) // Extension provides dynamic extension point for Telemetry. type Extension interface { - FetchMetrics(ctx context.Context, config Config) ([]*pmmv1.ServerMetric_Metric, error) + FetchMetrics(ctx context.Context, config Config) ([]*telemetryv1.GenericReport_Metric, error) } diff --git a/managed/services/telemetry/mock_data_source_test.go b/managed/services/telemetry/mock_data_source_test.go index a84586e7e1..e6b004ebb5 100644 --- a/managed/services/telemetry/mock_data_source_test.go +++ b/managed/services/telemetry/mock_data_source_test.go @@ -5,7 +5,7 @@ package telemetry import ( context "context" - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" + genericv1 "github.com/percona/saas/gen/telemetry/generic" mock "github.com/stretchr/testify/mock" ) @@ -51,23 +51,23 @@ func (_m *mockDataSource) Enabled() bool { } // FetchMetrics provides a mock function with given fields: ctx, config -func (_m *mockDataSource) FetchMetrics(ctx context.Context, config Config) ([]*pmmv1.ServerMetric_Metric, error) { +func (_m *mockDataSource) FetchMetrics(ctx context.Context, config Config) ([]*genericv1.GenericReport_Metric, error) { ret := _m.Called(ctx, config) if len(ret) == 0 { panic("no return value specified for FetchMetrics") } - var r0 []*pmmv1.ServerMetric_Metric + var r0 []*genericv1.GenericReport_Metric var r1 error - if rf, ok := ret.Get(0).(func(context.Context, Config) ([]*pmmv1.ServerMetric_Metric, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, Config) ([]*genericv1.GenericReport_Metric, error)); ok { return rf(ctx, config) } - if rf, ok := ret.Get(0).(func(context.Context, Config) []*pmmv1.ServerMetric_Metric); ok { + if rf, ok := ret.Get(0).(func(context.Context, Config) []*genericv1.GenericReport_Metric); ok { r0 = rf(ctx, config) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*pmmv1.ServerMetric_Metric) + r0 = ret.Get(0).([]*genericv1.GenericReport_Metric) } } diff --git a/managed/services/telemetry/mock_distribution_util_service_test.go b/managed/services/telemetry/mock_distribution_util_service_test.go index baa81ac8e8..d4c8871399 100644 --- a/managed/services/telemetry/mock_distribution_util_service_test.go +++ b/managed/services/telemetry/mock_distribution_util_service_test.go @@ -3,7 +3,7 @@ package telemetry import ( - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" + pmmv1 "github.com/percona/saas/gen/telemetry/events/pmm" mock "github.com/stretchr/testify/mock" serverv1 "github.com/percona/pmm/api/server/v1" diff --git a/managed/services/telemetry/mock_sender_test.go b/managed/services/telemetry/mock_sender_test.go index 41e73bd34e..3c943e8de4 100644 --- a/managed/services/telemetry/mock_sender_test.go +++ b/managed/services/telemetry/mock_sender_test.go @@ -5,7 +5,7 @@ package telemetry import ( context "context" - reporterv1 "github.com/percona-platform/saas/gen/telemetry/reporter" + genericv1 "github.com/percona/saas/gen/telemetry/generic" mock "github.com/stretchr/testify/mock" ) @@ -15,7 +15,7 @@ type mockSender struct { } // SendTelemetry provides a mock function with given fields: ctx, report -func (_m *mockSender) SendTelemetry(ctx context.Context, report *reporterv1.ReportRequest) error { +func (_m *mockSender) SendTelemetry(ctx context.Context, report *genericv1.ReportRequest) error { ret := _m.Called(ctx, report) if len(ret) == 0 { @@ -23,7 +23,7 @@ func (_m *mockSender) SendTelemetry(ctx context.Context, report *reporterv1.Repo } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *reporterv1.ReportRequest) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *genericv1.ReportRequest) error); ok { r0 = rf(ctx, report) } else { r0 = ret.Error(0) diff --git a/managed/services/telemetry/telemetry.go b/managed/services/telemetry/telemetry.go index 966ee5ec27..073b821080 100644 --- a/managed/services/telemetry/telemetry.go +++ b/managed/services/telemetry/telemetry.go @@ -18,14 +18,13 @@ package telemetry import ( "context" - "encoding/hex" "strings" "sync" "time" "github.com/google/uuid" - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" - reporter "github.com/percona-platform/saas/gen/telemetry/reporter" + pmmv1 "github.com/percona/saas/gen/telemetry/events/pmm" + telemetryv1 "github.com/percona/saas/gen/telemetry/generic" "github.com/pkg/errors" "github.com/sirupsen/logrus" "google.golang.org/protobuf/types/known/durationpb" @@ -53,7 +52,7 @@ type Service struct { os string sDistributionMethod serverv1.DistributionMethod tDistributionMethod pmmv1.DistributionMethod - sendCh chan *pmmv1.ServerMetric + sendCh chan *telemetryv1.GenericReport dataSourcesMap map[DataSourceName]DataSource extensions map[ExtensionType]Extension @@ -89,7 +88,7 @@ func NewService(db *reform.DB, portalClient *platform.Client, pmmVersion string, config: config, dsRegistry: registry, dus: dus, - sendCh: make(chan *pmmv1.ServerMetric, sendChSize), + sendCh: make(chan *telemetryv1.GenericReport, sendChSize), extensions: extensions, } @@ -167,7 +166,7 @@ func (s *Service) DistributionMethod() serverv1.DistributionMethod { func (s *Service) processSendCh(ctx context.Context) { var reportsBufSync sync.Mutex - var reportsBuf []*pmmv1.ServerMetric + var reportsBuf []*telemetryv1.GenericReport var sendCtx context.Context //nolint:contextcheck var cancel context.CancelFunc @@ -184,12 +183,12 @@ func (s *Service) processSendCh(ctx context.Context) { reportsBufSync.Lock() reportsBuf = append(reportsBuf, report) reportsToSend := reportsBuf - reportsBuf = []*pmmv1.ServerMetric{} + reportsBuf = []*telemetryv1.GenericReport{} reportsBufSync.Unlock() go func(ctx context.Context) { - err := s.send(ctx, &reporter.ReportRequest{ - Metrics: reportsToSend, + err := s.send(ctx, &telemetryv1.ReportRequest{ + Reports: reportsToSend, }) if err != nil { s.l.Debugf("Telemetry info not sent, due to error: %s.", err) @@ -211,7 +210,7 @@ func (s *Service) processSendCh(ctx context.Context) { } } -func (s *Service) prepareReport(ctx context.Context) *pmmv1.ServerMetric { +func (s *Service) prepareReport(ctx context.Context) *telemetryv1.GenericReport { initializedDataSources := make(map[DataSourceName]DataSource) telemetryMetric, _ := s.makeMetric(ctx) var totalTime time.Duration @@ -324,7 +323,7 @@ func (s *Service) locateDataSources(telemetryConfig []Config) map[DataSourceName return dataSources } -func (s *Service) makeMetric(ctx context.Context) (*pmmv1.ServerMetric, error) { +func (s *Service) makeMetric(ctx context.Context) (*telemetryv1.GenericReport, error) { var settings *models.Settings useServerID := false err := s.db.InTransaction(func(tx *reform.TX) error { @@ -348,27 +347,25 @@ func (s *Service) makeMetric(ctx context.Context) (*pmmv1.ServerMetric, error) { return nil, err } - var serverIDToUse string + var serverID string if useServerID { - serverIDToUse = strings.ReplaceAll(settings.PMMServerID, "-", "") + serverID = settings.PMMServerID } else { - serverIDToUse = settings.Telemetry.UUID + serverID = settings.Telemetry.UUID } - serverID, err := hex.DecodeString(serverIDToUse) - if err != nil { - return nil, errors.Wrapf(err, "failed to decode UUID %s", serverIDToUse) - } _, distMethod, _ := s.dus.GetDistributionMethodAndOS() - eventID := uuid.New() - return &pmmv1.ServerMetric{ - Id: eventID[:], - Time: timestamppb.New(time.Now()), - PmmServerTelemetryId: serverID, - PmmServerVersion: s.pmmVersion, - UpDuration: durationpb.New(time.Since(s.start)), - DistributionMethod: distMethod, + return &telemetryv1.GenericReport{ + Id: uuid.New().String(), + CreateTime: timestamppb.New(time.Now()), + InstanceId: uuid.MustParse(serverID).String(), + ProductFamily: telemetryv1.ProductFamily_PRODUCT_FAMILY_PMM, + Metrics: []*telemetryv1.GenericReport_Metric{ + {Key: "PMMServerVersion", Value: s.pmmVersion}, + {Key: "UpDuration", Value: durationpb.New(time.Since(s.start)).String()}, + {Key: "DistributionMethod", Value: distMethod.String()}, + }, }, nil } @@ -378,12 +375,10 @@ func generateUUID() (string, error) { return "", errors.Wrap(err, "can't generate UUID") } - // Old telemetry IDs have only 32 chars in the table but UUIDs + "-" = 36 - cleanUUID := strings.ReplaceAll(uuid.String(), "-", "") - return cleanUUID, nil + return uuid.String(), nil } -func (s *Service) send(ctx context.Context, report *reporter.ReportRequest) error { +func (s *Service) send(ctx context.Context, report *telemetryv1.ReportRequest) error { var err error var attempt int for { @@ -412,7 +407,7 @@ func (s *Service) send(ctx context.Context, report *reporter.ReportRequest) erro } // Format returns the formatted representation of the provided server metric. -func (s *Service) Format(report *pmmv1.ServerMetric) string { +func (s *Service) Format(report *telemetryv1.GenericReport) string { var builder strings.Builder for _, m := range report.Metrics { builder.WriteString(m.Key) diff --git a/managed/services/telemetry/telemetry_test.go b/managed/services/telemetry/telemetry_test.go index ac463b6589..fe13e1a968 100644 --- a/managed/services/telemetry/telemetry_test.go +++ b/managed/services/telemetry/telemetry_test.go @@ -23,8 +23,8 @@ import ( "time" _ "github.com/ClickHouse/clickhouse-go/v2" - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" - reporter "github.com/percona-platform/saas/gen/telemetry/reporter" + pmmv1 "github.com/percona/saas/gen/telemetry/events/pmm" + telemetryv1 "github.com/percona/saas/gen/telemetry/generic" "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -82,7 +82,11 @@ func TestRunTelemetryService(t *testing.T) { logger.SetLevel(logrus.DebugLevel) logEntry := logrus.NewEntry(logger) - expectedServerMetrics := []*pmmv1.ServerMetric_Metric{ + expectedServerMetrics := []*telemetryv1.GenericReport_Metric{ + { + Key: "DistributionMethod", + Value: pmmv1.DistributionMethod_AMI.String(), + }, { Key: "key", Value: "value", @@ -96,11 +100,10 @@ func TestRunTelemetryService(t *testing.T) { Value: "value3", }, } - expectedReport := &reporter.ReportRequest{ - Metrics: []*pmmv1.ServerMetric{ + expectedReport := &telemetryv1.ReportRequest{ + Reports: []*telemetryv1.GenericReport{ { - DistributionMethod: pmmv1.DistributionMethod_AMI, - Metrics: expectedServerMetrics, + Metrics: expectedServerMetrics, }, }, } @@ -176,7 +179,7 @@ func TestRunTelemetryService(t *testing.T) { tDistributionMethod: 0, dus: tt.fields.dus, portalClient: tt.mockTelemetrySender(), - sendCh: make(chan *pmmv1.ServerMetric, sendChSize), + sendCh: make(chan *telemetryv1.GenericReport, sendChSize), } s.Run(ctx) }) @@ -274,14 +277,14 @@ func getDistributionUtilService(t *testing.T, l *logrus.Entry) distributionUtilS return dus } -func initMockTelemetrySender(t *testing.T, expectedReport *reporter.ReportRequest, timesCall int) func() sender { +func initMockTelemetrySender(t *testing.T, expectedReport *telemetryv1.ReportRequest, timesCall int) func() sender { t.Helper() return func() sender { var mockTelemetrySender mockSender mockTelemetrySender.Test(t) mockTelemetrySender.On("SendTelemetry", mock.Anything, - mock.MatchedBy(func(report *reporter.ReportRequest) bool { + mock.MatchedBy(func(report *telemetryv1.ReportRequest) bool { return matchExpectedReport(report, expectedReport) }), ). @@ -295,9 +298,18 @@ func initMockTelemetrySender(t *testing.T, expectedReport *reporter.ReportReques } } -func matchExpectedReport(report *reporter.ReportRequest, expectedReport *reporter.ReportRequest) bool { - return len(report.Metrics) == 1 && - expectedReport.Metrics[0].DistributionMethod.String() == "AMI" +func valueIsInArray(items []*telemetryv1.GenericReport_Metric, value string) bool { + for _, item := range items { + if item.Value == value { + return true + } + } + + return false +} + +func matchExpectedReport(report *telemetryv1.ReportRequest, expectedReport *telemetryv1.ReportRequest) bool { + return len(report.Reports) == 1 && valueIsInArray(expectedReport.Reports[0].Metrics, "AMI") } func getTestConfig(sendOnStart bool, testSourceName string, reportingInterval time.Duration) ServiceConfig { diff --git a/managed/services/telemetry/transform.go b/managed/services/telemetry/transform.go index 2616c7317b..da20fa6508 100644 --- a/managed/services/telemetry/transform.go +++ b/managed/services/telemetry/transform.go @@ -18,13 +18,13 @@ package telemetry import ( "encoding/json" - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" + telemetryv1 "github.com/percona/saas/gen/telemetry/generic" "github.com/pkg/errors" ) type itemsType []map[string]any -func transformToJSON(config *Config, metrics []*pmmv1.ServerMetric_Metric) ([]*pmmv1.ServerMetric_Metric, error) { +func transformToJSON(config *Config, metrics []*telemetryv1.GenericReport_Metric) ([]*telemetryv1.GenericReport_Metric, error) { if len(metrics) == 0 { return metrics, nil } @@ -78,7 +78,7 @@ func transformToJSON(config *Config, metrics []*pmmv1.ServerMetric_Metric) ([]*p return nil, err } - return []*pmmv1.ServerMetric_Metric{ + return []*telemetryv1.GenericReport_Metric{ { Key: config.Transform.Metric, Value: string(resultAsJSON), @@ -86,7 +86,7 @@ func transformToJSON(config *Config, metrics []*pmmv1.ServerMetric_Metric) ([]*p }, nil } -func transformExportValues(config *Config, metrics []*pmmv1.ServerMetric_Metric) ([]*pmmv1.ServerMetric_Metric, error) { +func transformExportValues(config *Config, metrics []*telemetryv1.GenericReport_Metric) ([]*telemetryv1.GenericReport_Metric, error) { if len(metrics) == 0 { return metrics, nil } @@ -107,8 +107,8 @@ func transformExportValues(config *Config, metrics []*pmmv1.ServerMetric_Metric) return metrics, nil } -func removeEmpty(metrics []*pmmv1.ServerMetric_Metric) []*pmmv1.ServerMetric_Metric { - result := make([]*pmmv1.ServerMetric_Metric, 0, len(metrics)) +func removeEmpty(metrics []*telemetryv1.GenericReport_Metric) []*telemetryv1.GenericReport_Metric { + result := make([]*telemetryv1.GenericReport_Metric, 0, len(metrics)) for _, metric := range metrics { if metric.Value != "" { diff --git a/managed/services/telemetry/transform_test.go b/managed/services/telemetry/transform_test.go index a991333b27..06018f3a87 100644 --- a/managed/services/telemetry/transform_test.go +++ b/managed/services/telemetry/transform_test.go @@ -18,22 +18,22 @@ package telemetry import ( "testing" - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" + telemetryv1 "github.com/percona/saas/gen/telemetry/generic" "github.com/stretchr/testify/assert" ) func TestTransformToJSON(t *testing.T) { type args struct { config *Config - metrics []*pmmv1.ServerMetric_Metric + metrics []*telemetryv1.GenericReport_Metric } - noMetrics := []*pmmv1.ServerMetric_Metric{} + noMetrics := []*telemetryv1.GenericReport_Metric{} tests := []struct { name string args args - want []*pmmv1.ServerMetric_Metric + want []*telemetryv1.GenericReport_Metric wantErr assert.ErrorAssertionFunc }{ { @@ -85,7 +85,7 @@ func TestTransformToJSON(t *testing.T) { name: "invalid seq", args: args{ config: configJSON(), - metrics: []*pmmv1.ServerMetric_Metric{ + metrics: []*telemetryv1.GenericReport_Metric{ {Key: "my-metric", Value: "v1"}, {Key: "b", Value: "v1"}, {Key: "b", Value: "v1"}, // <--- will override second metric @@ -99,14 +99,14 @@ func TestTransformToJSON(t *testing.T) { name: "correct seq", args: args{ config: configJSON(), - metrics: []*pmmv1.ServerMetric_Metric{ + metrics: []*telemetryv1.GenericReport_Metric{ {Key: "my-metric", Value: "v1"}, {Key: "b", Value: "v1"}, {Key: "my-metric", Value: "v1"}, {Key: "b", Value: "v1"}, }, }, - want: []*pmmv1.ServerMetric_Metric{ + want: []*telemetryv1.GenericReport_Metric{ {Key: configJSON().Transform.Metric, Value: `{"v":[{"b":"v1","my-metric":"v1"},{"b":"v1","my-metric":"v1"}]}`}, }, wantErr: assert.NoError, @@ -115,12 +115,12 @@ func TestTransformToJSON(t *testing.T) { name: "happy path", args: args{ config: configJSON(), - metrics: []*pmmv1.ServerMetric_Metric{ + metrics: []*telemetryv1.GenericReport_Metric{ {Key: configJSON().Data[0].MetricName, Value: "v1"}, {Key: configJSON().Data[0].MetricName, Value: "v2"}, }, }, - want: []*pmmv1.ServerMetric_Metric{ + want: []*telemetryv1.GenericReport_Metric{ {Key: configJSON().Transform.Metric, Value: `{"v":[{"my-metric":"v1"},{"my-metric":"v2"}]}`}, }, wantErr: assert.NoError, @@ -135,14 +135,14 @@ func TestTransformToJSON(t *testing.T) { {MetricName: "4", Label: "status"}, {MetricName: "5", Label: "type"}, }), - metrics: []*pmmv1.ServerMetric_Metric{ + metrics: []*telemetryv1.GenericReport_Metric{ {Key: "licence", Value: `GPL`}, {Key: "name", Value: `INNODB_TABLES`}, {Key: "status", Value: `ACTIVE`}, {Key: "type", Value: `INFORMATION SCHEMA`}, }, }, - want: []*pmmv1.ServerMetric_Metric{ + want: []*telemetryv1.GenericReport_Metric{ {Key: "metric", Value: `{"v":[{"licence":"GPL","name":"INNODB_TABLES","status":"ACTIVE","type":"INFORMATION SCHEMA"}]}`}, }, wantErr: assert.NoError, @@ -164,15 +164,15 @@ func TestTransformToJSON(t *testing.T) { func TestTransformExportValues(t *testing.T) { type args struct { config *Config - metrics []*pmmv1.ServerMetric_Metric + metrics []*telemetryv1.GenericReport_Metric } - noMetrics := []*pmmv1.ServerMetric_Metric{} + noMetrics := []*telemetryv1.GenericReport_Metric{} tests := []struct { name string args args - want []*pmmv1.ServerMetric_Metric + want []*telemetryv1.GenericReport_Metric wantErr assert.ErrorAssertionFunc }{ { @@ -215,7 +215,7 @@ func TestTransformExportValues(t *testing.T) { name: "invalid data source", args: args{ config: configEnvVars().changeDataSource(dsPMMDBSelect), - metrics: []*pmmv1.ServerMetric_Metric{ + metrics: []*telemetryv1.GenericReport_Metric{ {Key: "metric-a", Value: "v1"}, {Key: "metric-b", Value: "v2"}, }, @@ -227,12 +227,12 @@ func TestTransformExportValues(t *testing.T) { name: "happy path", args: args{ config: configEnvVars(), - metrics: []*pmmv1.ServerMetric_Metric{ + metrics: []*telemetryv1.GenericReport_Metric{ {Key: "metric-a", Value: "v1"}, {Key: "metric-b", Value: "v2"}, }, }, - want: []*pmmv1.ServerMetric_Metric{ + want: []*telemetryv1.GenericReport_Metric{ {Key: "metric-a", Value: "1"}, {Key: "metric-b", Value: "1"}, }, @@ -300,16 +300,16 @@ func (c *Config) changeData(d []ConfigData) *Config { func TestRemoveEmpty(t *testing.T) { type args struct { - metrics []*pmmv1.ServerMetric_Metric + metrics []*telemetryv1.GenericReport_Metric } tests := []struct { name string args args - want []*pmmv1.ServerMetric_Metric + want []*telemetryv1.GenericReport_Metric }{ { name: "should remove metrics with empty values", - args: args{metrics: []*pmmv1.ServerMetric_Metric{ + args: args{metrics: []*telemetryv1.GenericReport_Metric{ { Key: "empty_value", Value: "", @@ -323,7 +323,7 @@ func TestRemoveEmpty(t *testing.T) { Value: "", }, }}, - want: []*pmmv1.ServerMetric_Metric{ + want: []*telemetryv1.GenericReport_Metric{ { Key: "not_empty", Value: "not_empty", @@ -332,7 +332,7 @@ func TestRemoveEmpty(t *testing.T) { }, { name: "should not remove anything if metrics are not empty", - args: args{metrics: []*pmmv1.ServerMetric_Metric{ + args: args{metrics: []*telemetryv1.GenericReport_Metric{ { Key: "not_empty", Value: "not_empty", @@ -342,7 +342,7 @@ func TestRemoveEmpty(t *testing.T) { Value: "not_empty", }, }}, - want: []*pmmv1.ServerMetric_Metric{ + want: []*telemetryv1.GenericReport_Metric{ { Key: "not_empty", Value: "not_empty", @@ -356,7 +356,7 @@ func TestRemoveEmpty(t *testing.T) { { name: "should not remove anything if metrics are not empty", args: args{metrics: nil}, - want: []*pmmv1.ServerMetric_Metric{}, + want: []*telemetryv1.GenericReport_Metric{}, }, } diff --git a/managed/services/telemetry/uievents/uievents.go b/managed/services/telemetry/uievents/uievents.go index bb981fc8a5..6d711616d3 100644 --- a/managed/services/telemetry/uievents/uievents.go +++ b/managed/services/telemetry/uievents/uievents.go @@ -24,7 +24,7 @@ import ( "time" "github.com/HdrHistogram/hdrhistogram-go" - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" + telemetryv1 "github.com/percona/saas/gen/telemetry/generic" "github.com/sirupsen/logrus" uieventsv1 "github.com/percona/pmm/api/uievents/v1" @@ -96,11 +96,11 @@ func (s *Service) ScheduleCleanup(ctx context.Context) { } // FetchMetrics fetches metrics for the service based on the provided context and telemetry configuration. -func (s *Service) FetchMetrics(_ context.Context, _ telemetry.Config) ([]*pmmv1.ServerMetric_Metric, error) { //nolint:unparam +func (s *Service) FetchMetrics(_ context.Context, _ telemetry.Config) ([]*telemetryv1.GenericReport_Metric, error) { //nolint:unparam s.stateM.RLock() defer s.stateM.RUnlock() - var result []*pmmv1.ServerMetric_Metric + var result []*telemetryv1.GenericReport_Metric if metric := s.processDashboardMetrics(); metric != nil { result = append(result, metric) } @@ -114,7 +114,7 @@ func (s *Service) FetchMetrics(_ context.Context, _ telemetry.Config) ([]*pmmv1. return result, nil } -func (s *Service) processDashboardMetrics() *pmmv1.ServerMetric_Metric { +func (s *Service) processDashboardMetrics() *telemetryv1.GenericReport_Metric { type Stat struct { TopDashboards []string `json:"top_dashboards"` SlowDashboardsP95_1s []string `json:"slow_dashboards_p95_1s"` @@ -170,13 +170,13 @@ func (s *Service) processDashboardMetrics() *pmmv1.ServerMetric_Metric { s.l.Error("failed to marshal to JSON") } - return &pmmv1.ServerMetric_Metric{ + return &telemetryv1.GenericReport_Metric{ Key: "ui-events-dashboards", Value: string(serializedDashboardStat), } } -func (s *Service) processComponentMetrics() *pmmv1.ServerMetric_Metric { +func (s *Service) processComponentMetrics() *telemetryv1.GenericReport_Metric { type Stat struct { SlowComponentsP95_1s []string `json:"slow_components_p95_1s"` SlowComponentsP95_5s []string `json:"slow_components_p95_5s"` @@ -220,20 +220,20 @@ func (s *Service) processComponentMetrics() *pmmv1.ServerMetric_Metric { if err != nil { s.l.Error("failed to marshal to JSON") } - return &pmmv1.ServerMetric_Metric{ + return &telemetryv1.GenericReport_Metric{ Key: "ui-events-components", Value: string(serializedComponentsStat), } } -func (s *Service) processUserFlowEvents() []*pmmv1.ServerMetric_Metric { - result := make([]*pmmv1.ServerMetric_Metric, 0, len(s.userFlowEvents)) +func (s *Service) processUserFlowEvents() []*telemetryv1.GenericReport_Metric { + result := make([]*telemetryv1.GenericReport_Metric, 0, len(s.userFlowEvents)) for _, event := range s.userFlowEvents { marshal, err := json.Marshal(event) if err != nil { s.l.Error("failed to marshal to JSON") } - result = append(result, &pmmv1.ServerMetric_Metric{ + result = append(result, &telemetryv1.GenericReport_Metric{ Key: "ui-events-user-flow", Value: string(marshal), }) diff --git a/managed/services/types.go b/managed/services/types.go index 805d2b7bc0..91ab54305c 100644 --- a/managed/services/types.go +++ b/managed/services/types.go @@ -16,7 +16,7 @@ package services import ( - "github.com/percona-platform/saas/pkg/check" + "github.com/percona/saas/pkg/check" "github.com/percona/pmm/managed/models" ) diff --git a/managed/utils/distribution/distribution_util.go b/managed/utils/distribution/distribution_util.go index e25f21b3b5..4a84e4c402 100644 --- a/managed/utils/distribution/distribution_util.go +++ b/managed/utils/distribution/distribution_util.go @@ -21,7 +21,7 @@ import ( "os" "regexp" - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" + pmmv1 "github.com/percona/saas/gen/telemetry/events/pmm" "github.com/sirupsen/logrus" serverv1 "github.com/percona/pmm/api/server/v1" diff --git a/managed/utils/distribution/distribution_util_test.go b/managed/utils/distribution/distribution_util_test.go index dca253ccd0..3aade6d0cd 100644 --- a/managed/utils/distribution/distribution_util_test.go +++ b/managed/utils/distribution/distribution_util_test.go @@ -19,7 +19,7 @@ import ( "os" "testing" - pmmv1 "github.com/percona-platform/saas/gen/telemetry/events/pmm" + pmmv1 "github.com/percona/saas/gen/telemetry/events/pmm" "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" diff --git a/managed/utils/platform/client.go b/managed/utils/platform/client.go index 28de38aefd..216365019a 100644 --- a/managed/utils/platform/client.go +++ b/managed/utils/platform/client.go @@ -24,8 +24,8 @@ import ( "io" "net/http" - api "github.com/percona-platform/saas/gen/check/retrieval" - reporter "github.com/percona-platform/saas/gen/telemetry/reporter" + api "github.com/percona/saas/gen/check/retrieval" + telemetryv1 "github.com/percona/saas/gen/telemetry/generic" "github.com/pkg/errors" "github.com/sirupsen/logrus" "google.golang.org/grpc/codes" @@ -118,8 +118,8 @@ func (c *Client) GetTemplates(ctx context.Context) (*api.GetAllAlertRuleTemplate } // SendTelemetry sends telemetry data to Percona Platform. -func (c *Client) SendTelemetry(ctx context.Context, report *reporter.ReportRequest) error { - const path = "/v1/telemetry/Report" +func (c *Client) SendTelemetry(ctx context.Context, report *telemetryv1.ReportRequest) error { + const path = "/v1/telemetry/GenericReport" var accessToken string if ssoDetails, err := models.GetPerconaSSODetails(ctx, c.db.Querier); err == nil { diff --git a/managed/utils/signatures/signatures.go b/managed/utils/signatures/signatures.go index 8d6d905d29..a1d79d5f2e 100644 --- a/managed/utils/signatures/signatures.go +++ b/managed/utils/signatures/signatures.go @@ -17,7 +17,7 @@ package signatures import ( - "github.com/percona-platform/saas/pkg/check" + "github.com/percona/saas/pkg/check" "github.com/pkg/errors" "github.com/sirupsen/logrus" )