From d6ddb63419526233cdad56a1e5f257d82c8b4faa Mon Sep 17 00:00:00 2001 From: Marcel Birkner Date: Fri, 15 Sep 2023 14:13:28 +0200 Subject: [PATCH] gocritic: switch ifelse with case statement --- cmd/telemetrygen/internal/metrics/worker.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/telemetrygen/internal/metrics/worker.go b/cmd/telemetrygen/internal/metrics/worker.go index 8b6c31efb3a4..59c390ea285a 100644 --- a/cmd/telemetrygen/internal/metrics/worker.go +++ b/cmd/telemetrygen/internal/metrics/worker.go @@ -33,19 +33,21 @@ func (w worker) simulateMetrics(res *resource.Resource, exporter sdkmetric.Expor var i int64 for w.running.Load() { var metrics []metricdata.Metrics - if w.metricType == metricTypeGauge { + + switch w.metricType { + case metricTypeGauge: metrics = append(metrics, metricdata.Metrics{ Name: "gen", Data: metricdata.Gauge[int64]{ DataPoints: []metricdata.DataPoint[int64]{ { - Time: time.Now(), - Value: i, + Time: time.Now(), + Value: i, }, }, }, }) - } else if w.metricType == metricTypeSum { + case metricTypeSum: metrics = append(metrics, metricdata.Metrics{ Name: "gen", Data: metricdata.Sum[int64]{ @@ -60,7 +62,7 @@ func (w worker) simulateMetrics(res *resource.Resource, exporter sdkmetric.Expor }, }, }) - } else { + default: w.logger.Fatal("unknown metric type") }