diff --git a/src/job/runner.go b/src/job/runner.go index 134e88ac..27974072 100644 --- a/src/job/runner.go +++ b/src/job/runner.go @@ -131,9 +131,7 @@ func (r *Runner) Run(ctx context.Context, logger *zap.Logger) { return } - if r.reporter != nil && metric != nil { - reportMetrics(r.reporter, metric, r.globalJobsCfg.ClientID, logger) - } + reportMetrics(r.reporter, metric, r.globalJobsCfg.ClientID, logger) } } @@ -160,7 +158,7 @@ func computeCount(count int, scaleFactor float64) int { } // if we have less than 1 goroutine per job we just filter them randomly so that only jobs*scaledCount pass - if rand.Float64() < scaledCount { + if rand.Float64() < scaledCount { //nolint:gosec // Cryptographically secure random not required return 1 } @@ -219,9 +217,11 @@ func (r *Runner) runJobs(ctx context.Context, cfg *config.MultiConfig, metric *m } func reportMetrics(reporter metrics.Reporter, metric *metrics.Metrics, clientID string, logger *zap.Logger) { - reporter.WriteSummary(metric) + if reporter != nil && metric != nil { + reporter.WriteSummary(metric) - if err := metrics.ReportStatistics(int64(metric.Sum(metrics.BytesSentStat)), clientID); err != nil { - logger.Debug("error reporting statistics", zap.Error(err)) + if err := metrics.ReportStatistics(int64(metric.Sum(metrics.BytesSentStat)), clientID); err != nil { + logger.Debug("error reporting statistics", zap.Error(err)) + } } } diff --git a/src/utils/utils.go b/src/utils/utils.go index ab78770a..0ba8da62 100644 --- a/src/utils/utils.go +++ b/src/utils/utils.go @@ -83,7 +83,9 @@ func GetEnvFloatDefault(key string, defaultValue float64) float64 { return defaultValue } - v, err := strconv.ParseFloat(value, 64) + const floatBits = 64 + + v, err := strconv.ParseFloat(value, floatBits) if err != nil { return defaultValue } @@ -91,7 +93,7 @@ func GetEnvFloatDefault(key string, defaultValue float64) float64 { return v } -func Max[T int|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|float32|float64](a, b T) T { +func Max[T int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | float32 | float64](a, b T) T { if a > b { return a }