From b4c048f16e49def9fc5b1ae6f0b838537a638d63 Mon Sep 17 00:00:00 2001 From: Korbinian Stoemmer Date: Tue, 18 Feb 2025 16:03:44 +0100 Subject: [PATCH 01/11] support floats for cpus and redis storage to allow for a more fine grained mapping of resources to "CPU" --- pkg/config/public_cloud_specs.go | 6 +- pkg/config/public_cloud_specs_test.go | 100 +++++++++++++++++- pkg/resource/node/scan_test.go | 52 ++++++++- pkg/resource/structures.go | 2 +- .../public_cloud_specs_fractional.json | 34 ++++++ .../fixtures/public_cloud_specs_no_aws.json | 6 -- .../fixtures/public_cloud_specs_no_azure.json | 6 -- .../fixtures/public_cloud_specs_no_ccee.json | 6 -- .../fixtures/public_cloud_specs_no_gcp.json | 6 -- .../fixtures/public_cloud_specs_no_redis.json | 59 ----------- .../fixtures/public_cloud_specs_small.json | 34 ++++++ 11 files changed, 221 insertions(+), 90 deletions(-) create mode 100644 pkg/testing/fixtures/public_cloud_specs_fractional.json create mode 100644 pkg/testing/fixtures/public_cloud_specs_small.json diff --git a/pkg/config/public_cloud_specs.go b/pkg/config/public_cloud_specs.go index 6d71d9f2..5af0ac22 100644 --- a/pkg/config/public_cloud_specs.go +++ b/pkg/config/public_cloud_specs.go @@ -30,13 +30,13 @@ type Providers struct { } type Feature struct { - CpuCores int `json:"cpu_cores"` + CpuCores float64 `json:"cpu_cores"` Memory float64 `json:"memory"` } type RedisInfo struct { - PriceStorageGB int `json:"price_storage_gb"` - PriceCapacityUnits int `json:"price_cu"` + PriceStorageGB float64 `json:"price_storage_gb"` + PriceCapacityUnits float64 `json:"price_cu"` } func (pcs *PublicCloudSpecs) GetFeature(cloudProvider, vmType string) *Feature { diff --git a/pkg/config/public_cloud_specs_test.go b/pkg/config/public_cloud_specs_test.go index a16c834a..be7c80d9 100644 --- a/pkg/config/public_cloud_specs_test.go +++ b/pkg/config/public_cloud_specs_test.go @@ -10,7 +10,8 @@ import ( ) const ( - testPublicCloudSpecsPath = "../testing/fixtures/public_cloud_specs.json" + testPublicCloudSpecsPath = "../testing/fixtures/public_cloud_specs.json" + testPublicCloudSpecsPathFractional = "../testing/fixtures/public_cloud_specs_fractional.json" ) func TestGetFeature(t *testing.T) { @@ -194,6 +195,65 @@ func TestGetFeature(t *testing.T) { } } +func TestGetFeatureFractional(t *testing.T) { + g := gomega.NewGomegaWithT(t) + config := &env.Config{PublicCloudSpecsPath: testPublicCloudSpecsPathFractional} + specs, err := LoadPublicCloudSpecs(config) + g.Expect(err).Should(gomega.BeNil()) + + testCases := []struct { + cloudProvider string + vmType string + expectedFeature Feature + wantNil bool + }{ + { + cloudProvider: "azure", + vmType: "standard_a1_v2", + expectedFeature: Feature{ + CpuCores: 1.1, + Memory: 2.1, + }, + }, + { + cloudProvider: "aws", + vmType: "m4.large", + expectedFeature: Feature{ + CpuCores: 2.2, + Memory: 8.2, + }, + }, + { + cloudProvider: "gcp", + vmType: "n1-standard-4", + expectedFeature: Feature{ + CpuCores: 4.3, + Memory: 15.3, + }, + }, + { + cloudProvider: "sapconvergedcloud", + vmType: "g_c12_m48", + expectedFeature: Feature{ + CpuCores: 12.4, + Memory: 48.4, + }, + }, + } + + for _, tc := range testCases { + t.Run(fmt.Sprintf("%s-%s", tc.cloudProvider, tc.vmType), func(t *testing.T) { + gotFeature := specs.GetFeature(tc.cloudProvider, tc.vmType) + if tc.wantNil { + g.Expect(gotFeature).Should(gomega.BeNil()) + return + } + + g.Expect(*gotFeature).Should(gomega.Equal(tc.expectedFeature)) + }) + } +} + func TestGetRedisInfo(t *testing.T) { g := gomega.NewGomegaWithT(t) config := &env.Config{PublicCloudSpecsPath: testPublicCloudSpecsPath} @@ -238,3 +298,41 @@ func TestGetRedisInfo(t *testing.T) { }) } } + +func TestGetRedisInfoFractional(t *testing.T) { + g := gomega.NewGomegaWithT(t) + config := &env.Config{PublicCloudSpecsPath: testPublicCloudSpecsPathFractional} + specs, err := LoadPublicCloudSpecs(config) + g.Expect(err).Should(gomega.BeNil()) + + testCases := []struct { + tier string + expectedRedis RedisInfo + wantNil bool + }{ + { + tier: "S1", + expectedRedis: RedisInfo{ + PriceStorageGB: 182.5, + PriceCapacityUnits: 74.5, + }, + }, + { + tier: "foo", + wantNil: true, + }, + } + + for _, tc := range testCases { + t.Run(tc.tier, func(t *testing.T) { + gotRedis := specs.GetRedisInfo(tc.tier) + if tc.wantNil { + g.Expect(gotRedis).Should(gomega.BeNil()) + return + } + + g.Expect(gotRedis).Should(gomega.Not(gomega.BeNil())) + g.Expect(*gotRedis).Should(gomega.Equal(tc.expectedRedis)) + }) + } +} diff --git a/pkg/resource/node/scan_test.go b/pkg/resource/node/scan_test.go index 1e0f1de1..852584a6 100644 --- a/pkg/resource/node/scan_test.go +++ b/pkg/resource/node/scan_test.go @@ -15,8 +15,9 @@ func TestScan_EDP(t *testing.T) { specs := &config.PublicCloudSpecs{ Providers: config.Providers{ AWS: map[string]config.Feature{ - "t2.micro": {CpuCores: 1, Memory: 1}, - "m5.large": {CpuCores: 2, Memory: 8}, + "t2.micro": {CpuCores: 1, Memory: 1}, + "m5.large": {CpuCores: 2, Memory: 8}, + "gpu.fake.fractional": {CpuCores: 1234.1234455, Memory: 1234.1234455}, }, Azure: map[string]config.Feature{ "a1.standard": {CpuCores: 1, Memory: 1.75}, @@ -66,6 +67,53 @@ func TestScan_EDP(t *testing.T) { }, expectedError: nil, }, + { + name: "single 'GPU' node", + provider: config.AWS, + list: metav1.PartialObjectMetadataList{ + Items: []metav1.PartialObjectMetadata{ + { + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{"node.kubernetes.io/instance-type": "gpu.fake.fractional"}, + }, + }, + }, + }, + expectedEDP: resource.EDPMeasurement{ + ProvisionedCPUs: 1234.1234455, + ProvisionedRAMGb: 1234.1234455, + VMTypes: []resource.VMType{ + {Name: "gpu.fake.fractional", Count: 1}, + }, + }, + expectedError: nil, + }, + { + name: "multiple 'GPU' nodes", + provider: config.AWS, + list: metav1.PartialObjectMetadataList{ + Items: []metav1.PartialObjectMetadata{ + { + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{"node.kubernetes.io/instance-type": "gpu.fake.fractional"}, + }, + }, + { + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{"node.kubernetes.io/instance-type": "gpu.fake.fractional"}, + }, + }, + }, + }, + expectedEDP: resource.EDPMeasurement{ + ProvisionedCPUs: 2468.246891, + ProvisionedRAMGb: 2468.246891, + VMTypes: []resource.VMType{ + {Name: "gpu.fake.fractional", Count: 2}, + }, + }, + expectedError: nil, + }, { name: "unknown node type", provider: config.AWS, diff --git a/pkg/resource/structures.go b/pkg/resource/structures.go index 172ba776..3cab25ec 100644 --- a/pkg/resource/structures.go +++ b/pkg/resource/structures.go @@ -2,7 +2,7 @@ package resource type EDPMeasurement struct { VMTypes []VMType `json:"vm_types" validate:"required"` - ProvisionedCPUs int `json:"provisioned_cpus" validate:"numeric"` + ProvisionedCPUs float64 `json:"provisioned_cpus" validate:"numeric"` ProvisionedRAMGb float64 `json:"provisioned_ram_gb" validate:"numeric"` ProvisionedVolumes ProvisionedVolumes `json:"provisioned_volumes" validate:"required"` } diff --git a/pkg/testing/fixtures/public_cloud_specs_fractional.json b/pkg/testing/fixtures/public_cloud_specs_fractional.json new file mode 100644 index 00000000..23325aa5 --- /dev/null +++ b/pkg/testing/fixtures/public_cloud_specs_fractional.json @@ -0,0 +1,34 @@ +{ + "providers" : { + "azure": { + "standard_a1_v2": { + "cpu_cores": 1.1, + "memory": 2.1 + } + }, + "aws": { + "m4.large": { + "cpu_cores": 2.2, + "memory": 8.2 + } + }, + "gcp": { + "n1-standard-4": { + "cpu_cores": 4.3, + "memory": 15.3 + } + }, + "sapconvergedcloud": { + "g_c12_m48": { + "cpu_cores": 12.4, + "memory": 48.4 + } + } + }, + "redis_tiers": { + "S1": { + "price_storage_gb": 182.5, + "price_cu": 74.5 + } + } +} diff --git a/pkg/testing/fixtures/public_cloud_specs_no_aws.json b/pkg/testing/fixtures/public_cloud_specs_no_aws.json index 627165b2..40fc37bd 100644 --- a/pkg/testing/fixtures/public_cloud_specs_no_aws.json +++ b/pkg/testing/fixtures/public_cloud_specs_no_aws.json @@ -6,12 +6,6 @@ "memory": 2 } }, - "aws": { - "m4.large": { - "cpu_cores": 2, - "memory": 8 - } - }, "gcp": { "n1-standard-4": { "cpu_cores": 4, diff --git a/pkg/testing/fixtures/public_cloud_specs_no_azure.json b/pkg/testing/fixtures/public_cloud_specs_no_azure.json index 627165b2..a7ce3c9a 100644 --- a/pkg/testing/fixtures/public_cloud_specs_no_azure.json +++ b/pkg/testing/fixtures/public_cloud_specs_no_azure.json @@ -1,11 +1,5 @@ { "providers" : { - "azure": { - "standard_a1_v2": { - "cpu_cores": 1, - "memory": 2 - } - }, "aws": { "m4.large": { "cpu_cores": 2, diff --git a/pkg/testing/fixtures/public_cloud_specs_no_ccee.json b/pkg/testing/fixtures/public_cloud_specs_no_ccee.json index 627165b2..121f51e5 100644 --- a/pkg/testing/fixtures/public_cloud_specs_no_ccee.json +++ b/pkg/testing/fixtures/public_cloud_specs_no_ccee.json @@ -17,12 +17,6 @@ "cpu_cores": 4, "memory": 15 } - }, - "sapconvergedcloud": { - "g_c12_m48": { - "cpu_cores": 12, - "memory": 48 - } } } } diff --git a/pkg/testing/fixtures/public_cloud_specs_no_gcp.json b/pkg/testing/fixtures/public_cloud_specs_no_gcp.json index 627165b2..9749df83 100644 --- a/pkg/testing/fixtures/public_cloud_specs_no_gcp.json +++ b/pkg/testing/fixtures/public_cloud_specs_no_gcp.json @@ -12,12 +12,6 @@ "memory": 8 } }, - "gcp": { - "n1-standard-4": { - "cpu_cores": 4, - "memory": 15 - } - }, "sapconvergedcloud": { "g_c12_m48": { "cpu_cores": 12, diff --git a/pkg/testing/fixtures/public_cloud_specs_no_redis.json b/pkg/testing/fixtures/public_cloud_specs_no_redis.json index d4976d33..27291b88 100644 --- a/pkg/testing/fixtures/public_cloud_specs_no_redis.json +++ b/pkg/testing/fixtures/public_cloud_specs_no_redis.json @@ -352,64 +352,5 @@ "memory": 8 } } - }, - - "redis_tiers": { - "S1": { - "price_storage_gb": 182, - "price_cu": 74 - }, - "S2": { - "price_storage_gb": 364, - "price_cu": 148 - }, - "S3": { - "price_storage_gb": 953, - "price_cu": 387 - }, - "S4": { - "price_storage_gb": 1915, - "price_cu": 778 - }, - "S5": { - "price_storage_gb": 3793, - "price_cu": 1541 - }, - "S6": { - "price_storage_gb": 7591, - "price_cu": 3084 - }, - "S7": { - "price_storage_gb": 15180, - "price_cu": 6167 - }, - "S8": { - "price_storage_gb": 30353, - "price_cu": 12331 - }, - "P1": { - "price_storage_gb": 1903, - "price_cu": 773 - }, - "P2": { - "price_storage_gb": 3828, - "price_cu": 1555 - }, - "P3": { - "price_storage_gb": 7586, - "price_cu": 3082 - }, - "P4": { - "price_storage_gb": 15180, - "price_cu": 6167 - }, - "P5": { - "price_storage_gb": 30363, - "price_cu": 12335 - }, - "P6": { - "price_storage_gb": 60704, - "price_cu": 24661 - } } } diff --git a/pkg/testing/fixtures/public_cloud_specs_small.json b/pkg/testing/fixtures/public_cloud_specs_small.json new file mode 100644 index 00000000..6acfab4f --- /dev/null +++ b/pkg/testing/fixtures/public_cloud_specs_small.json @@ -0,0 +1,34 @@ +{ + "providers" : { + "azure": { + "standard_a1_v2": { + "cpu_cores": 1, + "memory": 2 + } + }, + "aws": { + "m4.large": { + "cpu_cores": 2, + "memory": 8 + } + }, + "gcp": { + "n1-standard-4": { + "cpu_cores": 4, + "memory": 15 + } + }, + "sapconvergedcloud": { + "g_c12_m48": { + "cpu_cores": 12, + "memory": 48 + } + } + }, + "redis_tiers": { + "S1": { + "price_storage_gb": 182, + "price_cu": 74 + } + } +} From 7a1f3b9ea65d1d0dca7379bc00fc6764f548a81f Mon Sep 17 00:00:00 2001 From: Korbinian Stoemmer Date: Tue, 18 Feb 2025 17:25:15 +0100 Subject: [PATCH 02/11] assign missing client factory --- cmd/main.go | 2 ++ pkg/runtime/clients.go | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/main.go b/cmd/main.go index d1ace566..470ce52b 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -3,6 +3,7 @@ package main import ( "context" "fmt" + "github.com/kyma-project/kyma-metrics-collector/pkg/runtime" "net/http" "net/http/pprof" "os" @@ -137,6 +138,7 @@ func main() { ScrapeInterval: opts.ScrapeInterval, Queue: queue.NewQueue("trackable-skrs"), WorkersPoolSize: opts.WorkerPoolSize, + ClientFactory: runtime.NewClientsFactory(), } // Start execution diff --git a/pkg/runtime/clients.go b/pkg/runtime/clients.go index 343871d9..cfe52403 100644 --- a/pkg/runtime/clients.go +++ b/pkg/runtime/clients.go @@ -26,7 +26,11 @@ type Clients struct { type ClientsFactory struct{} -func (r ClientsFactory) NewClients(config *rest.Config) (*Clients, error) { +func NewClientsFactory() *ClientsFactory { + return &ClientsFactory{} +} + +func (r *ClientsFactory) NewClients(config *rest.Config) (InterfaceCloser, error) { return NewClients(config) } From 23f2c9dde4eae92bfdf7d1c2c5c23d13c5233127 Mon Sep 17 00:00:00 2001 From: Korbinian Stoemmer Date: Tue, 18 Feb 2025 18:22:40 +0100 Subject: [PATCH 03/11] process constructor --- cmd/main.go | 31 +++++++++++++---------------- pkg/process/process.go | 44 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 20 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 470ce52b..77949e68 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -3,7 +3,6 @@ package main import ( "context" "fmt" - "github.com/kyma-project/kyma-metrics-collector/pkg/runtime" "net/http" "net/http/pprof" "os" @@ -11,7 +10,6 @@ import ( "github.com/gorilla/mux" "github.com/kelseyhightower/envconfig" - gocache "github.com/patrickmn/go-cache" "github.com/prometheus/client_golang/prometheus/promhttp" "go.uber.org/zap" "k8s.io/client-go/kubernetes" @@ -26,7 +24,6 @@ import ( kmcmetrics "github.com/kyma-project/kyma-metrics-collector/pkg/metrics" kmcotel "github.com/kyma-project/kyma-metrics-collector/pkg/otel" kmcprocess "github.com/kyma-project/kyma-metrics-collector/pkg/process" - "github.com/kyma-project/kyma-metrics-collector/pkg/queue" "github.com/kyma-project/kyma-metrics-collector/pkg/resource/node" "github.com/kyma-project/kyma-metrics-collector/pkg/resource/pvc" "github.com/kyma-project/kyma-metrics-collector/pkg/resource/redis" @@ -94,9 +91,6 @@ func main() { kebClient := keb.NewClient(kebConfig, logger) logger.Debugf("keb config: %v", kebConfig) - // Creating kubeconfigprovider with no expiration and the data will never be cleaned up - cache := gocache.New(gocache.NoExpiration, gocache.NoExpiration) - // Creating EDP client edpConfig := new(edp.Config) if err := envconfig.Process("", edpConfig); err != nil { @@ -127,18 +121,19 @@ func main() { kubeconfigProvider := kubeconfigprovider.New(secretCacheClient.CoreV1(), logger, opts.KubeconfigCacheTTL, kubeconfigProviderName) - kmcProcess := kmcprocess.Process{ - KEBClient: kebClient, - EDPClient: edpClient, - EDPCollector: edpCollector, - KubeconfigProvider: kubeconfigProvider, - Logger: logger, - PublicCloudSpecs: publicCloudSpecs, - Cache: cache, - ScrapeInterval: opts.ScrapeInterval, - Queue: queue.NewQueue("trackable-skrs"), - WorkersPoolSize: opts.WorkerPoolSize, - ClientFactory: runtime.NewClientsFactory(), + kmcProcess, err := kmcprocess.New( + kebClient, + edpClient, + edpCollector, + kubeconfigProvider, + publicCloudSpecs, + opts.ScrapeInterval, + opts.WorkerPoolSize, + logger, + ) + + if err != nil { + logger.With(log.KeyResult, log.ValueFail).With(log.KeyError, err.Error()).Fatal("Create KMC process") } // Start execution diff --git a/pkg/process/process.go b/pkg/process/process.go index 3c6dba9b..6d815c60 100644 --- a/pkg/process/process.go +++ b/pkg/process/process.go @@ -2,10 +2,11 @@ package process import ( "fmt" + "github.com/kyma-project/kyma-metrics-collector/pkg/queue" "sync" "time" - "github.com/patrickmn/go-cache" + gocache "github.com/patrickmn/go-cache" "go.uber.org/zap" "k8s.io/client-go/util/workqueue" @@ -22,7 +23,7 @@ type Process struct { EDPCollector collector.CollectorSender Queue workqueue.TypedDelayingInterface[string] KubeconfigProvider runtime.ConfigProvider - Cache *cache.Cache + Cache *gocache.Cache PublicCloudSpecs *config.PublicCloudSpecs ScrapeInterval time.Duration WorkersPoolSize int @@ -35,6 +36,45 @@ const ( trackableFalse = false ) +// New creates a new Process object. +func New( + kebClient *keb.Client, + edpClient *edp.Client, + edpCollector collector.CollectorSender, + configProvider runtime.ConfigProvider, + publicCloudSpecs *config.PublicCloudSpecs, + scrapeInterval time.Duration, + workerPoolSize int, + logger *zap.SugaredLogger, +) (*Process, error) { + switch { + case logger == nil, + configProvider == nil, + publicCloudSpecs == nil, + edpCollector == nil, + edpClient == nil, + kebClient == nil: + return nil, fmt.Errorf("missing required parameter") + } + + // Creating kubeconfigprovider with no expiration and the data will never be cleaned up + cache := gocache.New(gocache.NoExpiration, gocache.NoExpiration) + + return &Process{ + KEBClient: kebClient, + EDPClient: edpClient, + EDPCollector: edpCollector, + KubeconfigProvider: configProvider, + Logger: logger, + PublicCloudSpecs: publicCloudSpecs, + Cache: cache, + ScrapeInterval: scrapeInterval, + Queue: queue.NewQueue("trackable-skrs"), + WorkersPoolSize: workerPoolSize, + ClientFactory: runtime.NewClientsFactory(), + }, nil +} + // Start runs the complete process of collection and sending metrics. func (p *Process) Start() { var wg sync.WaitGroup From 5b9d0b630443c88a955d0fc3544cefc4bbec2394 Mon Sep 17 00:00:00 2001 From: Korbinian Stoemmer Date: Tue, 18 Feb 2025 18:46:21 +0100 Subject: [PATCH 04/11] rename Epsilon to Delta --- cmd/main.go | 1 - pkg/collector/edp/collector_test.go | 8 ++++---- pkg/process/process.go | 2 +- pkg/resource/node/scan_test.go | 4 ++-- pkg/testing/helpers.go | 4 ++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 77949e68..318839ba 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -131,7 +131,6 @@ func main() { opts.WorkerPoolSize, logger, ) - if err != nil { logger.With(log.KeyResult, log.ValueFail).With(log.KeyError, err.Error()).Fatal("Create KMC process") } diff --git a/pkg/collector/edp/collector_test.go b/pkg/collector/edp/collector_test.go index 8b4c4dfe..2462fd81 100644 --- a/pkg/collector/edp/collector_test.go +++ b/pkg/collector/edp/collector_test.go @@ -378,7 +378,7 @@ func checkPrometheusMetrics(t *testing.T, scannerID1, scannerID2 resource.Scanne runtimeInfo.GlobalAccountID, ) require.NoError(t, err) - require.InEpsilon(t, float64(1), testutil.ToFloat64(gotMetrics), kmctesting.Epsilon) + require.InEpsilon(t, float64(1), testutil.ToFloat64(gotMetrics), kmctesting.Delta) // metrics: totalScans for scanner2 gotMetrics, err = collector.TotalScans.GetMetricWithLabelValues( @@ -391,7 +391,7 @@ func checkPrometheusMetrics(t *testing.T, scannerID1, scannerID2 resource.Scanne runtimeInfo.GlobalAccountID, ) require.NoError(t, err) - require.InEpsilon(t, float64(1), testutil.ToFloat64(gotMetrics), kmctesting.Epsilon) + require.InEpsilon(t, float64(1), testutil.ToFloat64(gotMetrics), kmctesting.Delta) // metrics: totalScansConverted for scanner1 gotMetrics, err = collector.TotalScansConverted.GetMetricWithLabelValues( @@ -405,7 +405,7 @@ func checkPrometheusMetrics(t *testing.T, scannerID1, scannerID2 resource.Scanne runtimeInfo.GlobalAccountID, ) require.NoError(t, err) - require.InEpsilon(t, float64(1), testutil.ToFloat64(gotMetrics), kmctesting.Epsilon) + require.InEpsilon(t, float64(1), testutil.ToFloat64(gotMetrics), kmctesting.Delta) // metrics: totalScansConverted for scanner2 gotMetrics, err = collector.TotalScansConverted.GetMetricWithLabelValues( @@ -419,7 +419,7 @@ func checkPrometheusMetrics(t *testing.T, scannerID1, scannerID2 resource.Scanne runtimeInfo.GlobalAccountID, ) require.NoError(t, err) - require.InEpsilon(t, float64(1), testutil.ToFloat64(gotMetrics), kmctesting.Epsilon) + require.InEpsilon(t, float64(1), testutil.ToFloat64(gotMetrics), kmctesting.Delta) } func expectedHeadersInEDPReq() http.Header { diff --git a/pkg/process/process.go b/pkg/process/process.go index 6d815c60..f78f93ed 100644 --- a/pkg/process/process.go +++ b/pkg/process/process.go @@ -2,7 +2,6 @@ package process import ( "fmt" - "github.com/kyma-project/kyma-metrics-collector/pkg/queue" "sync" "time" @@ -14,6 +13,7 @@ import ( "github.com/kyma-project/kyma-metrics-collector/pkg/collector/edp" "github.com/kyma-project/kyma-metrics-collector/pkg/config" "github.com/kyma-project/kyma-metrics-collector/pkg/keb" + "github.com/kyma-project/kyma-metrics-collector/pkg/queue" "github.com/kyma-project/kyma-metrics-collector/pkg/runtime" ) diff --git a/pkg/resource/node/scan_test.go b/pkg/resource/node/scan_test.go index 852584a6..5f7b5f70 100644 --- a/pkg/resource/node/scan_test.go +++ b/pkg/resource/node/scan_test.go @@ -198,8 +198,8 @@ func TestScan_EDP(t *testing.T) { actualEDP, err := scan.EDP() - require.Equal(t, test.expectedEDP.ProvisionedCPUs, actualEDP.ProvisionedCPUs) - require.InDelta(t, test.expectedEDP.ProvisionedRAMGb, actualEDP.ProvisionedRAMGb, kmctesting.Epsilon) + require.InDelta(t, test.expectedEDP.ProvisionedCPUs, actualEDP.ProvisionedCPUs, kmctesting.Delta) + require.InDelta(t, test.expectedEDP.ProvisionedRAMGb, actualEDP.ProvisionedRAMGb, kmctesting.Delta) require.ElementsMatch(t, test.expectedEDP.VMTypes, actualEDP.VMTypes) if test.expectedError != nil { diff --git a/pkg/testing/helpers.go b/pkg/testing/helpers.go index 839e045f..5e3fc9f7 100644 --- a/pkg/testing/helpers.go +++ b/pkg/testing/helpers.go @@ -21,8 +21,8 @@ import ( ) const ( - // Epsilon is used to compare floating point numbers using testify's InDelta and InEpsilon. - Epsilon = 0.0001 + // Delta is used to compare floating point numbers using testify's InDelta. + Delta = 1.0e-4 ) const ( From e15c42a6b3d167fefce824b44657c45f1cd46bfa Mon Sep 17 00:00:00 2001 From: Korbinian Stoemmer Date: Wed, 19 Feb 2025 08:26:54 +0100 Subject: [PATCH 05/11] move files --- docs/contributor/README.md | 4 +- .../contributor/assets/dev-stage-schema.json | 0 docs/contributor/assets/edp.json | 269 ------------------ .../contributor/assets/prod-schema.json | 0 4 files changed, 2 insertions(+), 271 deletions(-) rename hack/schema/dev-stage/schema.json => docs/contributor/assets/dev-stage-schema.json (100%) delete mode 100644 docs/contributor/assets/edp.json rename hack/schema/prod/schema.json => docs/contributor/assets/prod-schema.json (100%) diff --git a/docs/contributor/README.md b/docs/contributor/README.md index 9443f415..6c92cf3e 100644 --- a/docs/contributor/README.md +++ b/docs/contributor/README.md @@ -26,7 +26,7 @@ The following steps happen periodically: ## EDP interface -The data sent to EDP must adhere to the schema you see in [edp.json](./assets/edp.json). +The data sent to EDP must adhere to the schema you see in [prod-schema.json](./assets/prod-schema.json). See the following example payload: @@ -60,4 +60,4 @@ See the following example payload: "provisioned_ips": 3 } } -``` \ No newline at end of file +``` diff --git a/hack/schema/dev-stage/schema.json b/docs/contributor/assets/dev-stage-schema.json similarity index 100% rename from hack/schema/dev-stage/schema.json rename to docs/contributor/assets/dev-stage-schema.json diff --git a/docs/contributor/assets/edp.json b/docs/contributor/assets/edp.json deleted file mode 100644 index 74773901..00000000 --- a/docs/contributor/assets/edp.json +++ /dev/null @@ -1,269 +0,0 @@ -{ - "jsonSchema": { - "description": "SKR Metering Schema.", - "properties": { - "runtime_id": { - "format": "string", - "examples": [ - "52e31334-4819-4f36-9651-8ccd2a29b880" - ], - "description": "Runtime Identifier", - "$id": "#/properties/runtime_id", - "default": "", - "title": "The Runtime Identifier Schema", - "type": "string" - }, - "timestamp": { - "format": "date-time", - "examples": [ - "2020-03-25T09:16:41+00:00" - ], - "description": "Event Creation Timestamp", - "$id": "#/properties/timestamp", - "default": "", - "title": "The Timestamp Schema", - "type": "string" - }, - "sub_account_id": { - "format": "string", - "examples": [ - "52e31334-4819-4f36-9651-8ccd2a29b881" - ], - "description": "Sub-Account Identifier", - "$id": "#/properties/sub_account_id", - "default": "", - "title": "The Sub-Account Identifier Schema", - "type": "string" - }, - "shoot_name": { - "format": "string", - "examples": [ - "c-7ea3c81" - ], - "description": "Shoot Name", - "$id": "#/properties/shoot_name", - "default": "", - "title": "The Shoot Name Schema", - "type": "string" - }, - "networking": { - "examples": [ - { - "provisioned_vnets": 2, - "provisioned_loadbalancers": 1, - "provisioned_ips": 3 - } - ], - "description": "Some networking controlling data.", - "$id": "#/properties/networking", - "properties": { - "provisioned_vnets": { - "examples": [ - 2 - ], - "description": "Number of virtual networks", - "$id": "#/properties/networking/properties/provisioned_vnets", - "default": 0, - "title": "The Provisioned_vnets Schema", - "type": "integer" - }, - "provisioned_ips": { - "examples": [ - 3 - ], - "description": "Number of IPs", - "$id": "#/properties/networking/properties/provisioned_ips", - "default": 0, - "title": "The Provisioned_ips Schema", - "type": "integer" - } - }, - "default": {}, - "title": "The Networking Schema", - "type": "object", - "required": [ - "provisioned_vnets", - "provisioned_ips" - ] - }, - "compute": { - "examples": [ - { - "provisioned_cpus": 24, - "provisioned_volumes": { - "size_gb_rounded": 192, - "count": 3, - "size_gb_total": 150 - }, - "vm_types": [ - { - "name": "Standard_D8_v3", - "count": 3 - }, - { - "name": "Standard_D6_v3", - "count": 2 - } - ], - "provisioned_ram_gb": 96 - } - ], - "description": "Contains Azure Compute metrics", - "$id": "#/properties/compute", - "properties": { - "vm_types": { - "description": "A list of VM types that have been used for this SKR instance.", - "items": { - "examples": [ - { - "name": "Standard_D8_v3", - "count": 3 - }, - { - "name": "Standard_D6_v3", - "count": 2 - } - ], - "description": "The Azure instance type name and the provisioned quantity at the time of the event.", - "$id": "#/properties/compute/properties/vm_types/items", - "properties": { - "name": { - "examples": [ - "Standard_D8_v3" - ], - "description": "Name of the instance type", - "$id": "#/properties/compute/properties/vm_types/items/properties/name", - "default": "", - "title": "The Name Schema", - "type": "string" - }, - "count": { - "examples": [ - 3 - ], - "description": "Quantity of the instances", - "$id": "#/properties/compute/properties/vm_types/items/properties/count", - "default": 0, - "title": "The Count Schema", - "type": "integer" - } - }, - "default": {}, - "title": "The Items Schema", - "type": "object", - "required": [ - "name", - "count" - ] - }, - "$id": "#/properties/compute/properties/vm_types", - "default": [], - "title": "The Vm_types Schema", - "type": "array" - }, - "provisioned_cpus": { - "examples": [ - 24 - ], - "description": "The total sum of all CPUs provisioned from all instances (number of instances * number of CPUs per instance)", - "$id": "#/properties/compute/properties/provisioned_cpus", - "default": 0, - "title": "The Provisioned_cpus Schema", - "type": "integer" - }, - "provisioned_ram_gb": { - "examples": [ - 96 - ], - "description": "The total sum of Memory (RAM) of all provisioned instances (number of instances * number of GB RAM per instance).", - "$id": "#/properties/compute/properties/provisioned_ram_gb", - "default": 0, - "title": "The Provisioned_ram_gb Schema", - "type": "integer" - }, - "provisioned_volumes": { - "examples": [ - { - "size_gb_rounded": 192, - "count": 3, - "size_gb_total": 150 - } - ], - "description": "Volumes (Disk) provisioned.", - "$id": "#/properties/compute/properties/provisioned_volumes", - "properties": { - "size_gb_total": { - "examples": [ - 150 - ], - "description": "The total GB disk space requested by a kyma instance", - "$id": "#/properties/compute/properties/provisioned_volumes/properties/size_gb_total", - "default": 0, - "title": "The Size_gb_total Schema", - "type": "integer" - }, - "count": { - "examples": [ - 3 - ], - "description": "The number of disks provisioned.", - "$id": "#/properties/compute/properties/provisioned_volumes/properties/count", - "default": 0, - "title": "The Count Schema", - "type": "integer" - }, - "size_gb_rounded": { - "examples": [ - 192 - ], - "description": "Azure charges disk in 32GB blocks. If one provisions e.g. 16GB, he still pays 32 GB. This value here is rounding up each volume to the next y 32 dividable number and sums these values up.", - "$id": "#/properties/compute/properties/provisioned_volumes/properties/size_gb_rounded", - "default": 0, - "title": "The Size_gb_rounded Schema", - "type": "integer" - } - }, - "default": {}, - "title": "The Provisioned_volumes Schema", - "type": "object", - "required": [ - "size_gb_total", - "count", - "size_gb_rounded" - ] - } - }, - "default": {}, - "title": "The Compute Schema", - "type": "object", - "required": [ - "vm_types", - "provisioned_cpus", - "provisioned_ram_gb", - "provisioned_volumes" - ] - } - }, - "title": "SKR Metering Schema", - "type": "object", - "required": [ - "timestamp", - "compute", - "networking" - ] - }, - "eventTimeField": "event.timestamp", - "storage": {}, - "storageFormat": "v1", - "minimumRetentionPolicy": "P0D", - "namespace": { - "account": { - "name": "kyma" - }, - "name": "default" - }, - "maximumRetentionPolicy": "P10Y", - "name": "kmc-consumption-metrics$1", - "deduplicationStrategy": "takeAny", - "defaultRetentionPolicy": "P10Y" -} diff --git a/hack/schema/prod/schema.json b/docs/contributor/assets/prod-schema.json similarity index 100% rename from hack/schema/prod/schema.json rename to docs/contributor/assets/prod-schema.json From 8c07291dbca176a8e9b63797d7ba28c09d986da4 Mon Sep 17 00:00:00 2001 From: Korbinian Stoemmer Date: Wed, 19 Feb 2025 08:32:30 +0100 Subject: [PATCH 06/11] reformat json --- docs/contributor/assets/dev-stage-schema.json | 474 ++++++++--------- docs/contributor/assets/prod-schema.json | 476 ++++++++---------- 2 files changed, 435 insertions(+), 515 deletions(-) diff --git a/docs/contributor/assets/dev-stage-schema.json b/docs/contributor/assets/dev-stage-schema.json index c33cd264..122eabd2 100644 --- a/docs/contributor/assets/dev-stage-schema.json +++ b/docs/contributor/assets/dev-stage-schema.json @@ -1,269 +1,229 @@ { - "jsonSchema": { - "description": "SKR Metering Schema.", + "jsonSchema": { + "description": "SKR Metering Schema.", + "properties": { + "runtime_id": { + "format": "string", + "examples": ["52e31334-4819-4f36-9651-8ccd2a29b880"], + "description": "Runtime Identifier", + "$id": "#/properties/runtime_id", + "default": "", + "title": "The Runtime Identifier Schema", + "type": "string" + }, + "timestamp": { + "format": "date-time", + "examples": ["2020-03-25T09:16:41+00:00"], + "description": "Event Creation Timestamp", + "$id": "#/properties/timestamp", + "default": "", + "title": "The Timestamp Schema", + "type": "string" + }, + "sub_account_id": { + "format": "string", + "examples": ["52e31334-4819-4f36-9651-8ccd2a29b881"], + "description": "Sub-Account Identifier", + "$id": "#/properties/sub_account_id", + "default": "", + "title": "The Sub-Account Identifier Schema", + "type": "string" + }, + "shoot_name": { + "format": "string", + "examples": ["c-7ea3c81"], + "description": "Shoot Name", + "$id": "#/properties/shoot_name", + "default": "", + "title": "The Shoot Name Schema", + "type": "string" + }, + "networking": { + "examples": [ + { + "provisioned_vnets": 2, + "provisioned_loadbalancers": 1, + "provisioned_ips": 3 + } + ], + "description": "Some networking controlling data.", + "$id": "#/properties/networking", "properties": { - "runtime_id": { - "format": "string", - "examples": [ - "52e31334-4819-4f36-9651-8ccd2a29b880" - ], - "description": "Runtime Identifier", - "$id": "#/properties/runtime_id", - "default": "", - "title": "The Runtime Identifier Schema", - "type": "string" - }, - "timestamp": { - "format": "date-time", - "examples": [ - "2020-03-25T09:16:41+00:00" - ], - "description": "Event Creation Timestamp", - "$id": "#/properties/timestamp", - "default": "", - "title": "The Timestamp Schema", - "type": "string" - }, - "sub_account_id": { - "format": "string", - "examples": [ - "52e31334-4819-4f36-9651-8ccd2a29b881" - ], - "description": "Sub-Account Identifier", - "$id": "#/properties/sub_account_id", - "default": "", - "title": "The Sub-Account Identifier Schema", - "type": "string" - }, - "shoot_name": { - "format": "string", - "examples": [ - "c-7ea3c81" - ], - "description": "Shoot Name", - "$id": "#/properties/shoot_name", - "default": "", - "title": "The Shoot Name Schema", - "type": "string" + "provisioned_vnets": { + "examples": [2], + "description": "Number of virtual networks", + "$id": "#/properties/networking/properties/provisioned_vnets", + "default": 0, + "title": "The Provisioned_vnets Schema", + "type": "integer" + }, + "provisioned_ips": { + "examples": [3], + "description": "Number of IPs", + "$id": "#/properties/networking/properties/provisioned_ips", + "default": 0, + "title": "The Provisioned_ips Schema", + "type": "integer" + } + }, + "default": {}, + "title": "The Networking Schema", + "type": "object", + "required": ["provisioned_vnets", "provisioned_ips"] + }, + "compute": { + "examples": [ + { + "provisioned_cpus": 24, + "provisioned_volumes": { + "size_gb_rounded": 192, + "count": 3, + "size_gb_total": 150 }, - "networking": { - "examples": [ - { - "provisioned_vnets": 2, - "provisioned_loadbalancers": 1, - "provisioned_ips": 3 - } - ], - "description": "Some networking controlling data.", - "$id": "#/properties/networking", - "properties": { - "provisioned_vnets": { - "examples": [ - 2 - ], - "description": "Number of virtual networks", - "$id": "#/properties/networking/properties/provisioned_vnets", - "default": 0, - "title": "The Provisioned_vnets Schema", - "type": "integer" - }, - "provisioned_ips": { - "examples": [ - 3 - ], - "description": "Number of IPs", - "$id": "#/properties/networking/properties/provisioned_ips", - "default": 0, - "title": "The Provisioned_ips Schema", - "type": "integer" - } + "vm_types": [ + { + "name": "Standard_D8_v3", + "count": 3 + }, + { + "name": "Standard_D6_v3", + "count": 2 + } + ], + "provisioned_ram_gb": 96 + } + ], + "description": "Contains Azure Compute metrics", + "$id": "#/properties/compute", + "properties": { + "vm_types": { + "description": "A list of VM types that have been used for this SKR instance.", + "items": { + "examples": [ + { + "name": "Standard_D8_v3", + "count": 3 }, - "default": {}, - "title": "The Networking Schema", - "type": "object", - "required": [ - "provisioned_vnets", - "provisioned_ips" - ] - }, - "compute": { - "examples": [ - { - "provisioned_cpus": 24, - "provisioned_volumes": { - "size_gb_rounded": 192, - "count": 3, - "size_gb_total": 150 - }, - "vm_types": [ - { - "name": "Standard_D8_v3", - "count": 3 - }, - { - "name": "Standard_D6_v3", - "count": 2 - } - ], - "provisioned_ram_gb": 96 - } - ], - "description": "Contains Azure Compute metrics", - "$id": "#/properties/compute", - "properties": { - "vm_types": { - "description": "A list of VM types that have been used for this SKR instance.", - "items": { - "examples": [ - { - "name": "Standard_D8_v3", - "count": 3 - }, - { - "name": "Standard_D6_v3", - "count": 2 - } - ], - "description": "The Azure instance type name and the provisioned quantity at the time of the event.", - "$id": "#/properties/compute/properties/vm_types/items", - "properties": { - "name": { - "examples": [ - "Standard_D8_v3" - ], - "description": "Name of the instance type", - "$id": "#/properties/compute/properties/vm_types/items/properties/name", - "default": "", - "title": "The Name Schema", - "type": "string" - }, - "count": { - "examples": [ - 3 - ], - "description": "Quantity of the instances", - "$id": "#/properties/compute/properties/vm_types/items/properties/count", - "default": 0, - "title": "The Count Schema", - "type": "integer" - } - }, - "default": {}, - "title": "The Items Schema", - "type": "object", - "required": [ - "name", - "count" - ] - }, - "$id": "#/properties/compute/properties/vm_types", - "default": [], - "title": "The Vm_types Schema", - "type": "array" - }, - "provisioned_cpus": { - "examples": [ - 24 - ], - "description": "The total sum of all CPUs provisioned from all instances (number of instances * number of CPUs per instance)", - "$id": "#/properties/compute/properties/provisioned_cpus", - "default": 0, - "title": "The Provisioned_cpus Schema", - "type": "integer" - }, - "provisioned_ram_gb": { - "examples": [ - 96 - ], - "description": "The total sum of Memory (RAM) of all provisioned instances (number of instances * number of GB RAM per instance).", - "$id": "#/properties/compute/properties/provisioned_ram_gb", - "default": 0, - "title": "The Provisioned_ram_gb Schema", - "type": "integer" - }, - "provisioned_volumes": { - "examples": [ - { - "size_gb_rounded": 192, - "count": 3, - "size_gb_total": 150 - } - ], - "description": "Volumes (Disk) provisioned.", - "$id": "#/properties/compute/properties/provisioned_volumes", - "properties": { - "size_gb_total": { - "examples": [ - 150 - ], - "description": "The total GB disk space requested by a kyma instance", - "$id": "#/properties/compute/properties/provisioned_volumes/properties/size_gb_total", - "default": 0, - "title": "The Size_gb_total Schema", - "type": "integer" - }, - "count": { - "examples": [ - 3 - ], - "description": "The number of disks provisioned.", - "$id": "#/properties/compute/properties/provisioned_volumes/properties/count", - "default": 0, - "title": "The Count Schema", - "type": "integer" - }, - "size_gb_rounded": { - "examples": [ - 192 - ], - "description": "Azure charges disk in 32GB blocks. If one provisions e.g. 16GB, he still pays 32 GB. This value here is rounding up each volume to the next y 32 dividable number and sums these values up.", - "$id": "#/properties/compute/properties/provisioned_volumes/properties/size_gb_rounded", - "default": 0, - "title": "The Size_gb_rounded Schema", - "type": "integer" - } - }, - "default": {}, - "title": "The Provisioned_volumes Schema", - "type": "object", - "required": [ - "size_gb_total", - "count", - "size_gb_rounded" - ] - } + { + "name": "Standard_D6_v3", + "count": 2 + } + ], + "description": "The Azure instance type name and the provisioned quantity at the time of the event.", + "$id": "#/properties/compute/properties/vm_types/items", + "properties": { + "name": { + "examples": ["Standard_D8_v3"], + "description": "Name of the instance type", + "$id": "#/properties/compute/properties/vm_types/items/properties/name", + "default": "", + "title": "The Name Schema", + "type": "string" }, - "default": {}, - "title": "The Compute Schema", - "type": "object", - "required": [ - "vm_types", - "provisioned_cpus", - "provisioned_ram_gb", - "provisioned_volumes" - ] - } + "count": { + "examples": [3], + "description": "Quantity of the instances", + "$id": "#/properties/compute/properties/vm_types/items/properties/count", + "default": 0, + "title": "The Count Schema", + "type": "integer" + } + }, + "default": {}, + "title": "The Items Schema", + "type": "object", + "required": ["name", "count"] + }, + "$id": "#/properties/compute/properties/vm_types", + "default": [], + "title": "The Vm_types Schema", + "type": "array" + }, + "provisioned_cpus": { + "examples": [24], + "description": "The total sum of all CPUs provisioned from all instances (number of instances * number of CPUs per instance)", + "$id": "#/properties/compute/properties/provisioned_cpus", + "default": 0, + "title": "The Provisioned_cpus Schema", + "type": "integer" + }, + "provisioned_ram_gb": { + "examples": [96], + "description": "The total sum of Memory (RAM) of all provisioned instances (number of instances * number of GB RAM per instance).", + "$id": "#/properties/compute/properties/provisioned_ram_gb", + "default": 0, + "title": "The Provisioned_ram_gb Schema", + "type": "integer" + }, + "provisioned_volumes": { + "examples": [ + { + "size_gb_rounded": 192, + "count": 3, + "size_gb_total": 150 + } + ], + "description": "Volumes (Disk) provisioned.", + "$id": "#/properties/compute/properties/provisioned_volumes", + "properties": { + "size_gb_total": { + "examples": [150], + "description": "The total GB disk space requested by a kyma instance", + "$id": "#/properties/compute/properties/provisioned_volumes/properties/size_gb_total", + "default": 0, + "title": "The Size_gb_total Schema", + "type": "integer" + }, + "count": { + "examples": [3], + "description": "The number of disks provisioned.", + "$id": "#/properties/compute/properties/provisioned_volumes/properties/count", + "default": 0, + "title": "The Count Schema", + "type": "integer" + }, + "size_gb_rounded": { + "examples": [192], + "description": "Azure charges disk in 32GB blocks. If one provisions e.g. 16GB, he still pays 32 GB. This value here is rounding up each volume to the next y 32 dividable number and sums these values up.", + "$id": "#/properties/compute/properties/provisioned_volumes/properties/size_gb_rounded", + "default": 0, + "title": "The Size_gb_rounded Schema", + "type": "integer" + } + }, + "default": {}, + "title": "The Provisioned_volumes Schema", + "type": "object", + "required": ["size_gb_total", "count", "size_gb_rounded"] + } }, - "title": "SKR Metering Schema", + "default": {}, + "title": "The Compute Schema", "type": "object", "required": [ - "timestamp", - "compute", - "networking" + "vm_types", + "provisioned_cpus", + "provisioned_ram_gb", + "provisioned_volumes" ] + } }, - "eventTimeField": "event.timestamp", - "storage": {}, - "storageFormat": "v1", - "minimumRetentionPolicy": "P0D", - "namespace": { - "account": { - "name": "kyma" - }, - "name": "dev" + "title": "SKR Metering Schema", + "type": "object", + "required": ["timestamp", "compute", "networking"] + }, + "eventTimeField": "event.timestamp", + "storage": {}, + "storageFormat": "v1", + "minimumRetentionPolicy": "P0D", + "namespace": { + "account": { + "name": "kyma" }, - "maximumRetentionPolicy": "P10Y", - "name": "kmc-consumption-metrics$1", - "deduplicationStrategy": "takeAny", - "defaultRetentionPolicy": "P10Y" + "name": "dev" + }, + "maximumRetentionPolicy": "P10Y", + "name": "kmc-consumption-metrics$1", + "deduplicationStrategy": "takeAny", + "defaultRetentionPolicy": "P10Y" } diff --git a/docs/contributor/assets/prod-schema.json b/docs/contributor/assets/prod-schema.json index 828addc3..186d06d2 100644 --- a/docs/contributor/assets/prod-schema.json +++ b/docs/contributor/assets/prod-schema.json @@ -1,269 +1,229 @@ { - "jsonSchema": { - "description": "SKR Metering Schema.", + "jsonSchema": { + "description": "SKR Metering Schema.", + "properties": { + "runtime_id": { + "format": "string", + "examples": ["52e31334-4819-4f36-9651-8ccd2a29b880"], + "description": "Runtime Identifier", + "$id": "#/properties/runtime_id", + "default": "", + "title": "The Runtime Identifier Schema", + "type": "string" + }, + "timestamp": { + "format": "date-time", + "examples": ["2020-03-25T09:16:41+00:00"], + "description": "Event Creation Timestamp", + "$id": "#/properties/timestamp", + "default": "", + "title": "The Timestamp Schema", + "type": "string" + }, + "sub_account_id": { + "format": "string", + "examples": ["52e31334-4819-4f36-9651-8ccd2a29b881"], + "description": "Sub-Account Identifier", + "$id": "#/properties/sub_account_id", + "default": "", + "title": "The Sub-Account Identifier Schema", + "type": "string" + }, + "shoot_name": { + "format": "string", + "examples": ["c-7ea3c81"], + "description": "Shoot Name", + "$id": "#/properties/shoot_name", + "default": "", + "title": "The Shoot Name Schema", + "type": "string" + }, + "networking": { + "examples": [ + { + "provisioned_vnets": 2, + "provisioned_loadbalancers": 1, + "provisioned_ips": 3 + } + ], + "description": "Some networking controlling data.", + "$id": "#/properties/networking", "properties": { - "runtime_id": { - "format": "string", - "examples": [ - "52e31334-4819-4f36-9651-8ccd2a29b880" - ], - "description": "Runtime Identifier", - "$id": "#/properties/runtime_id", - "default": "", - "title": "The Runtime Identifier Schema", - "type": "string" - }, - "timestamp": { - "format": "date-time", - "examples": [ - "2020-03-25T09:16:41+00:00" - ], - "description": "Event Creation Timestamp", - "$id": "#/properties/timestamp", - "default": "", - "title": "The Timestamp Schema", - "type": "string" - }, - "sub_account_id": { - "format": "string", - "examples": [ - "52e31334-4819-4f36-9651-8ccd2a29b881" - ], - "description": "Sub-Account Identifier", - "$id": "#/properties/sub_account_id", - "default": "", - "title": "The Sub-Account Identifier Schema", - "type": "string" - }, - "shoot_name": { - "format": "string", - "examples": [ - "c-7ea3c81" - ], - "description": "Shoot Name", - "$id": "#/properties/shoot_name", - "default": "", - "title": "The Shoot Name Schema", - "type": "string" + "provisioned_vnets": { + "examples": [2], + "description": "Number of virtual networks", + "$id": "#/properties/networking/properties/provisioned_vnets", + "default": 0, + "title": "The Provisioned_vnets Schema", + "type": "integer" + }, + "provisioned_ips": { + "examples": [3], + "description": "Number of IPs", + "$id": "#/properties/networking/properties/provisioned_ips", + "default": 0, + "title": "The Provisioned_ips Schema", + "type": "integer" + } + }, + "default": {}, + "title": "The Networking Schema", + "type": "object", + "required": ["provisioned_vnets", "provisioned_ips"] + }, + "compute": { + "examples": [ + { + "provisioned_cpus": 24, + "provisioned_volumes": { + "size_gb_rounded": 192, + "count": 3, + "size_gb_total": 150 }, - "networking": { - "examples": [ - { - "provisioned_vnets": 2, - "provisioned_loadbalancers": 1, - "provisioned_ips": 3 - } - ], - "description": "Some networking controlling data.", - "$id": "#/properties/networking", - "properties": { - "provisioned_vnets": { - "examples": [ - 2 - ], - "description": "Number of virtual networks", - "$id": "#/properties/networking/properties/provisioned_vnets", - "default": 0, - "title": "The Provisioned_vnets Schema", - "type": "integer" - }, - "provisioned_ips": { - "examples": [ - 3 - ], - "description": "Number of IPs", - "$id": "#/properties/networking/properties/provisioned_ips", - "default": 0, - "title": "The Provisioned_ips Schema", - "type": "integer" - } + "vm_types": [ + { + "name": "Standard_D8_v3", + "count": 3 + }, + { + "name": "Standard_D6_v3", + "count": 2 + } + ], + "provisioned_ram_gb": 96 + } + ], + "description": "Contains Azure Compute metrics", + "$id": "#/properties/compute", + "properties": { + "vm_types": { + "description": "A list of VM types that have been used for this SKR instance.", + "items": { + "examples": [ + { + "name": "Standard_D8_v3", + "count": 3 }, - "default": {}, - "title": "The Networking Schema", - "type": "object", - "required": [ - "provisioned_vnets", - "provisioned_ips" - ] - }, - "compute": { - "examples": [ - { - "provisioned_cpus": 24, - "provisioned_volumes": { - "size_gb_rounded": 192, - "count": 3, - "size_gb_total": 150 - }, - "vm_types": [ - { - "name": "Standard_D8_v3", - "count": 3 - }, - { - "name": "Standard_D6_v3", - "count": 2 - } - ], - "provisioned_ram_gb": 96 - } - ], - "description": "Contains Azure Compute metrics", - "$id": "#/properties/compute", - "properties": { - "vm_types": { - "description": "A list of VM types that have been used for this SKR instance.", - "items": { - "examples": [ - { - "name": "Standard_D8_v3", - "count": 3 - }, - { - "name": "Standard_D6_v3", - "count": 2 - } - ], - "description": "The Azure instance type name and the provisioned quantity at the time of the event.", - "$id": "#/properties/compute/properties/vm_types/items", - "properties": { - "name": { - "examples": [ - "Standard_D8_v3" - ], - "description": "Name of the instance type", - "$id": "#/properties/compute/properties/vm_types/items/properties/name", - "default": "", - "title": "The Name Schema", - "type": "string" - }, - "count": { - "examples": [ - 3 - ], - "description": "Quantity of the instances", - "$id": "#/properties/compute/properties/vm_types/items/properties/count", - "default": 0, - "title": "The Count Schema", - "type": "integer" - } - }, - "default": {}, - "title": "The Items Schema", - "type": "object", - "required": [ - "name", - "count" - ] - }, - "$id": "#/properties/compute/properties/vm_types", - "default": [], - "title": "The Vm_types Schema", - "type": "array" - }, - "provisioned_cpus": { - "examples": [ - 24 - ], - "description": "The total sum of all CPUs provisioned from all instances (number of instances * number of CPUs per instance)", - "$id": "#/properties/compute/properties/provisioned_cpus", - "default": 0, - "title": "The Provisioned_cpus Schema", - "type": "integer" - }, - "provisioned_ram_gb": { - "examples": [ - 96 - ], - "description": "The total sum of Memory (RAM) of all provisioned instances (number of instances * number of GB RAM per instance).", - "$id": "#/properties/compute/properties/provisioned_ram_gb", - "default": 0, - "title": "The Provisioned_ram_gb Schema", - "type": "integer" - }, - "provisioned_volumes": { - "examples": [ - { - "size_gb_rounded": 192, - "count": 3, - "size_gb_total": 150 - } - ], - "description": "Volumes (Disk) provisioned.", - "$id": "#/properties/compute/properties/provisioned_volumes", - "properties": { - "size_gb_total": { - "examples": [ - 150 - ], - "description": "The total GB disk space requested by a kyma instance", - "$id": "#/properties/compute/properties/provisioned_volumes/properties/size_gb_total", - "default": 0, - "title": "The Size_gb_total Schema", - "type": "integer" - }, - "count": { - "examples": [ - 3 - ], - "description": "The number of disks provisioned.", - "$id": "#/properties/compute/properties/provisioned_volumes/properties/count", - "default": 0, - "title": "The Count Schema", - "type": "integer" - }, - "size_gb_rounded": { - "examples": [ - 192 - ], - "description": "Azure charges disk in 32GB blocks. If one provisions e.g. 16GB, he still pays 32 GB. This value here is rounding up each volume to the next y 32 dividable number and sums these values up.", - "$id": "#/properties/compute/properties/provisioned_volumes/properties/size_gb_rounded", - "default": 0, - "title": "The Size_gb_rounded Schema", - "type": "integer" - } - }, - "default": {}, - "title": "The Provisioned_volumes Schema", - "type": "object", - "required": [ - "size_gb_total", - "count", - "size_gb_rounded" - ] - } + { + "name": "Standard_D6_v3", + "count": 2 + } + ], + "description": "The Azure instance type name and the provisioned quantity at the time of the event.", + "$id": "#/properties/compute/properties/vm_types/items", + "properties": { + "name": { + "examples": ["Standard_D8_v3"], + "description": "Name of the instance type", + "$id": "#/properties/compute/properties/vm_types/items/properties/name", + "default": "", + "title": "The Name Schema", + "type": "string" }, - "default": {}, - "title": "The Compute Schema", - "type": "object", - "required": [ - "vm_types", - "provisioned_cpus", - "provisioned_ram_gb", - "provisioned_volumes" - ] - } + "count": { + "examples": [3], + "description": "Quantity of the instances", + "$id": "#/properties/compute/properties/vm_types/items/properties/count", + "default": 0, + "title": "The Count Schema", + "type": "integer" + } + }, + "default": {}, + "title": "The Items Schema", + "type": "object", + "required": ["name", "count"] + }, + "$id": "#/properties/compute/properties/vm_types", + "default": [], + "title": "The Vm_types Schema", + "type": "array" + }, + "provisioned_cpus": { + "examples": [24], + "description": "The total sum of all CPUs provisioned from all instances (number of instances * number of CPUs per instance)", + "$id": "#/properties/compute/properties/provisioned_cpus", + "default": 0, + "title": "The Provisioned_cpus Schema", + "type": "integer" + }, + "provisioned_ram_gb": { + "examples": [96], + "description": "The total sum of Memory (RAM) of all provisioned instances (number of instances * number of GB RAM per instance).", + "$id": "#/properties/compute/properties/provisioned_ram_gb", + "default": 0, + "title": "The Provisioned_ram_gb Schema", + "type": "integer" + }, + "provisioned_volumes": { + "examples": [ + { + "size_gb_rounded": 192, + "count": 3, + "size_gb_total": 150 + } + ], + "description": "Volumes (Disk) provisioned.", + "$id": "#/properties/compute/properties/provisioned_volumes", + "properties": { + "size_gb_total": { + "examples": [150], + "description": "The total GB disk space requested by a kyma instance", + "$id": "#/properties/compute/properties/provisioned_volumes/properties/size_gb_total", + "default": 0, + "title": "The Size_gb_total Schema", + "type": "integer" + }, + "count": { + "examples": [3], + "description": "The number of disks provisioned.", + "$id": "#/properties/compute/properties/provisioned_volumes/properties/count", + "default": 0, + "title": "The Count Schema", + "type": "integer" + }, + "size_gb_rounded": { + "examples": [192], + "description": "Azure charges disk in 32GB blocks. If one provisions e.g. 16GB, he still pays 32 GB. This value here is rounding up each volume to the next y 32 dividable number and sums these values up.", + "$id": "#/properties/compute/properties/provisioned_volumes/properties/size_gb_rounded", + "default": 0, + "title": "The Size_gb_rounded Schema", + "type": "integer" + } + }, + "default": {}, + "title": "The Provisioned_volumes Schema", + "type": "object", + "required": ["size_gb_total", "count", "size_gb_rounded"] + } }, - "title": "SKR Metering Schema", + "default": {}, + "title": "The Compute Schema", "type": "object", "required": [ - "timestamp", - "compute", - "networking" + "vm_types", + "provisioned_cpus", + "provisioned_ram_gb", + "provisioned_volumes" ] + } }, - "eventTimeField": "event.timestamp", - "storage": {}, - "storageFormat": "v1", - "minimumRetentionPolicy": "P0D", - "namespace": { - "account": { - "name": "kyma" - }, - "name": "default" + "title": "SKR Metering Schema", + "type": "object", + "required": ["timestamp", "compute", "networking"] + }, + "eventTimeField": "event.timestamp", + "storage": {}, + "storageFormat": "v1", + "minimumRetentionPolicy": "P0D", + "namespace": { + "account": { + "name": "kyma" }, - "maximumRetentionPolicy": "P10Y", - "name": "kmc-consumption-metrics$1", - "deduplicationStrategy": "takeAny", - "defaultRetentionPolicy": "P10Y" -} \ No newline at end of file + "name": "default" + }, + "maximumRetentionPolicy": "P10Y", + "name": "kmc-consumption-metrics$1", + "deduplicationStrategy": "takeAny", + "defaultRetentionPolicy": "P10Y" +} From 7b529961b44b5097394655ee7fdf26fc72ba443e Mon Sep 17 00:00:00 2001 From: Korbinian Stoemmer Date: Wed, 19 Feb 2025 08:34:36 +0100 Subject: [PATCH 07/11] update schema to support floating point numbers --- docs/contributor/assets/dev-stage-schema.json | 12 ++++++------ docs/contributor/assets/prod-schema.json | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/contributor/assets/dev-stage-schema.json b/docs/contributor/assets/dev-stage-schema.json index 122eabd2..29e03848 100644 --- a/docs/contributor/assets/dev-stage-schema.json +++ b/docs/contributor/assets/dev-stage-schema.json @@ -145,7 +145,7 @@ "$id": "#/properties/compute/properties/provisioned_cpus", "default": 0, "title": "The Provisioned_cpus Schema", - "type": "integer" + "type": "number" }, "provisioned_ram_gb": { "examples": [96], @@ -153,7 +153,7 @@ "$id": "#/properties/compute/properties/provisioned_ram_gb", "default": 0, "title": "The Provisioned_ram_gb Schema", - "type": "integer" + "type": "number" }, "provisioned_volumes": { "examples": [ @@ -172,7 +172,7 @@ "$id": "#/properties/compute/properties/provisioned_volumes/properties/size_gb_total", "default": 0, "title": "The Size_gb_total Schema", - "type": "integer" + "type": "number" }, "count": { "examples": [3], @@ -180,7 +180,7 @@ "$id": "#/properties/compute/properties/provisioned_volumes/properties/count", "default": 0, "title": "The Count Schema", - "type": "integer" + "type": "number" }, "size_gb_rounded": { "examples": [192], @@ -188,7 +188,7 @@ "$id": "#/properties/compute/properties/provisioned_volumes/properties/size_gb_rounded", "default": 0, "title": "The Size_gb_rounded Schema", - "type": "integer" + "type": "number" } }, "default": {}, @@ -210,7 +210,7 @@ }, "title": "SKR Metering Schema", "type": "object", - "required": ["timestamp", "compute", "networking"] + "required": ["timestamp", "compute"] }, "eventTimeField": "event.timestamp", "storage": {}, diff --git a/docs/contributor/assets/prod-schema.json b/docs/contributor/assets/prod-schema.json index 186d06d2..ec2f42d7 100644 --- a/docs/contributor/assets/prod-schema.json +++ b/docs/contributor/assets/prod-schema.json @@ -145,7 +145,7 @@ "$id": "#/properties/compute/properties/provisioned_cpus", "default": 0, "title": "The Provisioned_cpus Schema", - "type": "integer" + "type": "number" }, "provisioned_ram_gb": { "examples": [96], @@ -153,7 +153,7 @@ "$id": "#/properties/compute/properties/provisioned_ram_gb", "default": 0, "title": "The Provisioned_ram_gb Schema", - "type": "integer" + "type": "number" }, "provisioned_volumes": { "examples": [ @@ -172,7 +172,7 @@ "$id": "#/properties/compute/properties/provisioned_volumes/properties/size_gb_total", "default": 0, "title": "The Size_gb_total Schema", - "type": "integer" + "type": "number" }, "count": { "examples": [3], @@ -180,7 +180,7 @@ "$id": "#/properties/compute/properties/provisioned_volumes/properties/count", "default": 0, "title": "The Count Schema", - "type": "integer" + "type": "number" }, "size_gb_rounded": { "examples": [192], @@ -188,7 +188,7 @@ "$id": "#/properties/compute/properties/provisioned_volumes/properties/size_gb_rounded", "default": 0, "title": "The Size_gb_rounded Schema", - "type": "integer" + "type": "number" } }, "default": {}, @@ -210,7 +210,7 @@ }, "title": "SKR Metering Schema", "type": "object", - "required": ["timestamp", "compute", "networking"] + "required": ["timestamp", "compute"] }, "eventTimeField": "event.timestamp", "storage": {}, From 88c777a9aed1d33426f9e6eb4f0b2840db568e38 Mon Sep 17 00:00:00 2001 From: Korbinian Stoemmer Date: Wed, 19 Feb 2025 16:00:47 +0100 Subject: [PATCH 08/11] revert allowing float64 for redis as it is not needed --- pkg/config/public_cloud_specs.go | 4 +- pkg/config/public_cloud_specs_test.go | 38 ------------------- .../public_cloud_specs_fractional.json | 4 +- 3 files changed, 4 insertions(+), 42 deletions(-) diff --git a/pkg/config/public_cloud_specs.go b/pkg/config/public_cloud_specs.go index 5af0ac22..45a8c8e8 100644 --- a/pkg/config/public_cloud_specs.go +++ b/pkg/config/public_cloud_specs.go @@ -35,8 +35,8 @@ type Feature struct { } type RedisInfo struct { - PriceStorageGB float64 `json:"price_storage_gb"` - PriceCapacityUnits float64 `json:"price_cu"` + PriceStorageGB int `json:"price_storage_gb"` + PriceCapacityUnits int `json:"price_cu"` } func (pcs *PublicCloudSpecs) GetFeature(cloudProvider, vmType string) *Feature { diff --git a/pkg/config/public_cloud_specs_test.go b/pkg/config/public_cloud_specs_test.go index be7c80d9..f16c4f03 100644 --- a/pkg/config/public_cloud_specs_test.go +++ b/pkg/config/public_cloud_specs_test.go @@ -298,41 +298,3 @@ func TestGetRedisInfo(t *testing.T) { }) } } - -func TestGetRedisInfoFractional(t *testing.T) { - g := gomega.NewGomegaWithT(t) - config := &env.Config{PublicCloudSpecsPath: testPublicCloudSpecsPathFractional} - specs, err := LoadPublicCloudSpecs(config) - g.Expect(err).Should(gomega.BeNil()) - - testCases := []struct { - tier string - expectedRedis RedisInfo - wantNil bool - }{ - { - tier: "S1", - expectedRedis: RedisInfo{ - PriceStorageGB: 182.5, - PriceCapacityUnits: 74.5, - }, - }, - { - tier: "foo", - wantNil: true, - }, - } - - for _, tc := range testCases { - t.Run(tc.tier, func(t *testing.T) { - gotRedis := specs.GetRedisInfo(tc.tier) - if tc.wantNil { - g.Expect(gotRedis).Should(gomega.BeNil()) - return - } - - g.Expect(gotRedis).Should(gomega.Not(gomega.BeNil())) - g.Expect(*gotRedis).Should(gomega.Equal(tc.expectedRedis)) - }) - } -} diff --git a/pkg/testing/fixtures/public_cloud_specs_fractional.json b/pkg/testing/fixtures/public_cloud_specs_fractional.json index 23325aa5..6c893d58 100644 --- a/pkg/testing/fixtures/public_cloud_specs_fractional.json +++ b/pkg/testing/fixtures/public_cloud_specs_fractional.json @@ -27,8 +27,8 @@ }, "redis_tiers": { "S1": { - "price_storage_gb": 182.5, - "price_cu": 74.5 + "price_storage_gb": 182, + "price_cu": 74 } } } From bb45e01a03e608ace8f7580ed6b2029c8769c06d Mon Sep 17 00:00:00 2001 From: Korbinian Stoemmer Date: Wed, 19 Feb 2025 16:02:35 +0100 Subject: [PATCH 09/11] remove unnecessary field --- pkg/config/public_cloud_specs_test.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pkg/config/public_cloud_specs_test.go b/pkg/config/public_cloud_specs_test.go index f16c4f03..00cd4bbc 100644 --- a/pkg/config/public_cloud_specs_test.go +++ b/pkg/config/public_cloud_specs_test.go @@ -205,7 +205,6 @@ func TestGetFeatureFractional(t *testing.T) { cloudProvider string vmType string expectedFeature Feature - wantNil bool }{ { cloudProvider: "azure", @@ -244,11 +243,6 @@ func TestGetFeatureFractional(t *testing.T) { for _, tc := range testCases { t.Run(fmt.Sprintf("%s-%s", tc.cloudProvider, tc.vmType), func(t *testing.T) { gotFeature := specs.GetFeature(tc.cloudProvider, tc.vmType) - if tc.wantNil { - g.Expect(gotFeature).Should(gomega.BeNil()) - return - } - g.Expect(*gotFeature).Should(gomega.Equal(tc.expectedFeature)) }) } From d318149da027297cfc4668fc035753795f0decd0 Mon Sep 17 00:00:00 2001 From: Korbinian Stoemmer Date: Thu, 20 Feb 2025 09:20:17 +0100 Subject: [PATCH 10/11] add logger --- cmd/main.go | 1 + pkg/collector/edp/collector.go | 7 ++++++- pkg/collector/edp/collector_test.go | 5 +++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 318839ba..ddf2a8cf 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -113,6 +113,7 @@ func main() { vscScanner := vsc.NewScanner() edpCollector := edp.NewCollector( edpClient, + logger, nodeScanner, pvcScanner, redisScanner, diff --git a/pkg/collector/edp/collector.go b/pkg/collector/edp/collector.go index 70729dcb..5ed8d417 100644 --- a/pkg/collector/edp/collector.go +++ b/pkg/collector/edp/collector.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "go.uber.org/zap" "net/http" "time" @@ -18,6 +19,7 @@ import ( ) type Collector struct { + logger *zap.SugaredLogger EDPClient *Client scanners []resource.Scanner } @@ -26,8 +28,9 @@ var errNoMeasurementsSent = errors.New("no measurements sent to EDP") var _ collector.CollectorSender = &Collector{} -func NewCollector(EDPClient *Client, scanner ...resource.Scanner) *Collector { +func NewCollector(EDPClient *Client, logger *zap.SugaredLogger, scanner ...resource.Scanner) *Collector { return &Collector{ + logger: logger, EDPClient: EDPClient, scanners: scanner, } @@ -72,6 +75,8 @@ func (c *Collector) CollectAndSend(ctx context.Context, runtime *runtime.Info, c EDPMeasurements, ) + c.logger.Debug("Sending payload to EDP", zap.Any("payload", payload)) + err = c.sendPayload(payload, runtime.SubAccountID) if err != nil { errs = append(errs, fmt.Errorf("failed to send payload to EDP: %w", err)) diff --git a/pkg/collector/edp/collector_test.go b/pkg/collector/edp/collector_test.go index 2462fd81..defa0b2e 100644 --- a/pkg/collector/edp/collector_test.go +++ b/pkg/collector/edp/collector_test.go @@ -335,9 +335,10 @@ func TestCollector_CollectAndSend(t *testing.T) { defer srv.Close() edpConfig := newEDPConfig(srv.URL) - edpClient := NewClient(edpConfig, logger.NewLogger(zapcore.DebugLevel)) + log := logger.NewLogger(zapcore.DebugLevel) + edpClient := NewClient(edpConfig, log) - EDPCollector := NewCollector(edpClient, scanner1, scanner2) + EDPCollector := NewCollector(edpClient, log, scanner1, scanner2) runtimeInfo := runtime.Info{ InstanceID: instanceID, From 4b43294d23062df98e191cc5076f9326ae1a8484 Mon Sep 17 00:00:00 2001 From: Korbinian Stoemmer Date: Thu, 20 Feb 2025 09:23:50 +0100 Subject: [PATCH 11/11] Revert "add logger" This reverts commit d318149da027297cfc4668fc035753795f0decd0. --- cmd/main.go | 1 - pkg/collector/edp/collector.go | 7 +------ pkg/collector/edp/collector_test.go | 5 ++--- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index ddf2a8cf..318839ba 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -113,7 +113,6 @@ func main() { vscScanner := vsc.NewScanner() edpCollector := edp.NewCollector( edpClient, - logger, nodeScanner, pvcScanner, redisScanner, diff --git a/pkg/collector/edp/collector.go b/pkg/collector/edp/collector.go index 5ed8d417..70729dcb 100644 --- a/pkg/collector/edp/collector.go +++ b/pkg/collector/edp/collector.go @@ -5,7 +5,6 @@ import ( "encoding/json" "errors" "fmt" - "go.uber.org/zap" "net/http" "time" @@ -19,7 +18,6 @@ import ( ) type Collector struct { - logger *zap.SugaredLogger EDPClient *Client scanners []resource.Scanner } @@ -28,9 +26,8 @@ var errNoMeasurementsSent = errors.New("no measurements sent to EDP") var _ collector.CollectorSender = &Collector{} -func NewCollector(EDPClient *Client, logger *zap.SugaredLogger, scanner ...resource.Scanner) *Collector { +func NewCollector(EDPClient *Client, scanner ...resource.Scanner) *Collector { return &Collector{ - logger: logger, EDPClient: EDPClient, scanners: scanner, } @@ -75,8 +72,6 @@ func (c *Collector) CollectAndSend(ctx context.Context, runtime *runtime.Info, c EDPMeasurements, ) - c.logger.Debug("Sending payload to EDP", zap.Any("payload", payload)) - err = c.sendPayload(payload, runtime.SubAccountID) if err != nil { errs = append(errs, fmt.Errorf("failed to send payload to EDP: %w", err)) diff --git a/pkg/collector/edp/collector_test.go b/pkg/collector/edp/collector_test.go index defa0b2e..2462fd81 100644 --- a/pkg/collector/edp/collector_test.go +++ b/pkg/collector/edp/collector_test.go @@ -335,10 +335,9 @@ func TestCollector_CollectAndSend(t *testing.T) { defer srv.Close() edpConfig := newEDPConfig(srv.URL) - log := logger.NewLogger(zapcore.DebugLevel) - edpClient := NewClient(edpConfig, log) + edpClient := NewClient(edpConfig, logger.NewLogger(zapcore.DebugLevel)) - EDPCollector := NewCollector(edpClient, log, scanner1, scanner2) + EDPCollector := NewCollector(edpClient, scanner1, scanner2) runtimeInfo := runtime.Info{ InstanceID: instanceID,