From b8f30e758180a84b635202870dae4cfafeee1924 Mon Sep 17 00:00:00 2001 From: Rajkiran Ramachandran Balasubramanian Date: Wed, 30 Mar 2022 16:36:41 -0700 Subject: [PATCH] Fix go linter errors (#185) --- .../receiver/metricgenerator/metric_generator.go | 4 ++-- .../receiver/vmagereceiver/vm_age_collector_test.go | 10 ++++++---- .../receiver/vmagereceiver/vm_age_constants.go | 7 +------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/opentelemetry_collector/receiver/metricgenerator/metric_generator.go b/opentelemetry_collector/receiver/metricgenerator/metric_generator.go index 2344a9e..b1cd33f 100644 --- a/opentelemetry_collector/receiver/metricgenerator/metric_generator.go +++ b/opentelemetry_collector/receiver/metricgenerator/metric_generator.go @@ -64,7 +64,7 @@ func FormatBucketOptions(bounds []float64) *metricspb.DistributionValue_BucketOp // MakeBuckets generates a proto representation of a distribution containing a single value. // bounds defines the bucket boundaries of the distribution. func MakeBuckets(values, bounds []float64) []*metricspb.DistributionValue_Bucket { - buckets := make([]*metricspb.DistributionValue_Bucket, len(bounds)+1, len(bounds)+1) + buckets := make([]*metricspb.DistributionValue_Bucket, len(bounds)+1) for i := 0; i <= len(bounds); i++ { buckets[i] = &metricspb.DistributionValue_Bucket{} } @@ -88,7 +88,7 @@ func getBucketIndex(val float64, bounds []float64) int { } func formatBuckets(distribution []int64) []*metricspb.DistributionValue_Bucket { - buckets := make([]*metricspb.DistributionValue_Bucket, len(distribution), len(distribution)) + buckets := make([]*metricspb.DistributionValue_Bucket, len(distribution)) for i := 0; i < len(distribution); i++ { buckets[i] = &metricspb.DistributionValue_Bucket{ Count: distribution[i], diff --git a/opentelemetry_collector/receiver/vmagereceiver/vm_age_collector_test.go b/opentelemetry_collector/receiver/vmagereceiver/vm_age_collector_test.go index eaaf544..388fa09 100644 --- a/opentelemetry_collector/receiver/vmagereceiver/vm_age_collector_test.go +++ b/opentelemetry_collector/receiver/vmagereceiver/vm_age_collector_test.go @@ -102,6 +102,8 @@ func TestParseInputTimesError(t *testing.T) { assert.Equal(t, tc.buildDateError, collector.buildDateError) assert.Equal(t, tc.vmStartTimeError, collector.vmStartTimeError) assert.Equal(t, tc.vmReadyTime, collector.vmReadyTime) + assert.Equal(t, tc.vmReadyTimeError, collector.vmReadyTimeError) + assert.Equal(t, tc.vmStartTimeError, collector.vmStartTimeError) } } @@ -147,15 +149,15 @@ func TestScrapeAndExportVMImageAge(t *testing.T) { assertMetricGreaterThan0Double(t, expectedDesc, c.storage.metrics) } -func scrapeAndExportVMReadyTime(t *testing.T) { +func TestScrapeAndExportVMReadyTime(t *testing.T) { consumer := fakeConsumer{storage: &metricsStore{}} collector := NewVMAgeCollector(0, testVMImageBuildDate, testVMImageName, testVMStartTime, testVMReadyTime, consumer, zap.NewNop()) collector.setupCollection() expectedDesc := &metricspb.MetricDescriptor{ - Name: "vm_image_age", - Description: "The VM image age for the VM instance", - Unit: "Days", + Name: "vm_ready_time", + Description: "The amount of time from when Flex first started setting up the VM in the startup script to when it finished setting up all VM runtime components.", + Unit: "Seconds", Type: metricspb.MetricDescriptor_GAUGE_DOUBLE, LabelKeys: []*metricspb.LabelKey{{ Key: "vm_image_name", diff --git a/opentelemetry_collector/receiver/vmagereceiver/vm_age_constants.go b/opentelemetry_collector/receiver/vmagereceiver/vm_age_constants.go index e1366d6..2122dfe 100644 --- a/opentelemetry_collector/receiver/vmagereceiver/vm_age_constants.go +++ b/opentelemetry_collector/receiver/vmagereceiver/vm_age_constants.go @@ -31,9 +31,4 @@ var vmReadyTimeMetric = &metricspb.MetricDescriptor{ Unit: "Seconds", Type: metricspb.MetricDescriptor_GAUGE_DOUBLE, LabelKeys: []*metricspb.LabelKey{vmImageNameLabel}, -} - -var ( - numBounds = float64(8) - boundsBase = float64(2) -) +} \ No newline at end of file