Skip to content

Commit bbad4f2

Browse files
committed
lint fixes
1 parent b8bf07a commit bbad4f2

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

operator/metrics/metricscollector.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package metrics
22

33
import (
4-
"github.com/kedacore/http-add-on/operator/controllers/http/config"
54
"go.opentelemetry.io/otel/exporters/prometheus"
65
ctrlmetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
6+
7+
"github.com/kedacore/http-add-on/operator/controllers/http/config"
78
)
89

910
var (

operator/metrics/otelmetrics.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"log"
66
"os"
77

8-
"github.com/kedacore/http-add-on/pkg/build"
98
"go.opentelemetry.io/otel/attribute"
109
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc"
1110
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp"
@@ -14,6 +13,8 @@ import (
1413
"go.opentelemetry.io/otel/sdk/resource"
1514
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
1615
logf "sigs.k8s.io/controller-runtime/pkg/log"
16+
17+
"github.com/kedacore/http-add-on/pkg/build"
1718
)
1819

1920
var otLog = logf.Log.WithName("otel_collector")
@@ -24,7 +25,6 @@ type OtelMetrics struct {
2425
}
2526

2627
func NewOtelMetrics(options ...metric.Option) *OtelMetrics {
27-
2828
if options == nil {
2929
protocol := os.Getenv("OTEL_EXPORTER_OTLP_PROTOCOL")
3030

operator/metrics/prommetrics.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import (
44
"context"
55
"log"
66

7-
"github.com/kedacore/http-add-on/pkg/build"
87
"go.opentelemetry.io/otel/attribute"
98
"go.opentelemetry.io/otel/exporters/prometheus"
109
api "go.opentelemetry.io/otel/metric"
1110
"go.opentelemetry.io/otel/sdk/metric"
1211
"go.opentelemetry.io/otel/sdk/resource"
1312
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
13+
14+
"github.com/kedacore/http-add-on/pkg/build"
1415
)
1516

1617
type PrometheusMetrics struct {

tests/checks/operator_otel_metrics/operator_otel_metrics_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,14 @@ func TestMetricGeneration(t *testing.T) {
188188
httpSacaledObjectCount := getMetricsValue(val)
189189
assert.GreaterOrEqual(t, httpSacaledObjectCount, float64(1))
190190

191-
//Set the operator to comunicate over GRPC and test functionality
191+
// Set the operator to comunicate over GRPC and test functionality
192192
changeOtlpProtocolInOperator(t, kc, "keda-add-ons-http-operator", "keda")
193193
CreateManyHttpScaledObjecs(t, 10)
194194
time.Sleep(time.Second * 10)
195195
family = fetchAndParsePrometheusMetrics(t, fmt.Sprintf("curl --insecure %s", otelCollectorPromURL))
196196
val, ok = family["keda_http_scaled_object_total"]
197+
assert.True(t, ok, "keda_http_scaled_object_total is available")
198+
197199
httpSacaledObjectCountGrpc := getMetricsValue(val)
198200
assert.GreaterOrEqual(t, httpSacaledObjectCountGrpc, float64(10))
199201

@@ -202,6 +204,8 @@ func TestMetricGeneration(t *testing.T) {
202204
// Fetch metrics and validate them after deleting httpscaledobjects
203205
family = fetchAndParsePrometheusMetrics(t, fmt.Sprintf("curl --insecure %s", otelCollectorPromURL))
204206
val, ok = family["keda_http_scaled_object_total"]
207+
assert.True(t, ok, "keda_http_scaled_object_total is available")
208+
205209
httpSacaledObjectCountAfterCleanUp := getMetricsValue(val)
206210
assert.Equal(t, float64(1), httpSacaledObjectCountAfterCleanUp)
207211

tests/checks/operator_prometheus_metrics/operator_prometheus_metrics_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ func TestMetricGeneration(t *testing.T) {
181181
// Fetch metrics and validate them after deleting httpscaledobjects
182182
family = fetchAndParsePrometheusMetrics(t, fmt.Sprintf("curl --insecure %s", kedaOperatorPrometheusURL))
183183
val, ok = family["keda_http_scaled_object_total"]
184+
assert.True(t, ok, "keda_http_scaled_object_total is available")
184185
httpSacaledObjectCountAfterCleanUp := getMetricsValue(val)
185186
assert.Equal(t, float64(1), httpSacaledObjectCountAfterCleanUp)
186187

@@ -213,7 +214,6 @@ func fetchAndParsePrometheusMetrics(t *testing.T, cmd string) map[string]*prommo
213214

214215
func getMetricsValue(val *prommodel.MetricFamily) float64 {
215216
if val.GetName() == "keda_http_scaled_object_total" {
216-
217217
metrics := val.GetMetric()
218218
for _, metric := range metrics {
219219
labels := metric.GetLabel()
@@ -270,12 +270,10 @@ func CreateManyHttpScaledObjecs(t *testing.T, objectsCount int) {
270270
httpScaledObjecData, httpScaledObjecDataTemplates := getTemplateHTTPScaledObjecData(fmt.Sprintf("%d", i))
271271
KubectlApplyMultipleWithTemplate(t, httpScaledObjecData, httpScaledObjecDataTemplates)
272272
}
273-
274273
}
275274
func DeleteManyHttpScaledObjecs(t *testing.T, objectsCount int) {
276275
for i := 0; i < objectsCount; i++ {
277276
httpScaledObjecData, httpScaledObjecDataTemplates := getTemplateHTTPScaledObjecData(fmt.Sprintf("%d", i))
278277
KubectlDeleteMultipleWithTemplate(t, httpScaledObjecData, httpScaledObjecDataTemplates)
279278
}
280-
281279
}

0 commit comments

Comments
 (0)