From e8aa18fc0e5cdf27cdb24301105290ec00d9da02 Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Sat, 11 May 2024 02:43:15 +0200 Subject: [PATCH] simplify Signed-off-by: Tim Vaillancourt --- go/streamlog/streamlog.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/go/streamlog/streamlog.go b/go/streamlog/streamlog.go index cec9806d90f..bb194287750 100644 --- a/go/streamlog/streamlog.go +++ b/go/streamlog/streamlog.go @@ -259,13 +259,12 @@ func GetFormatter[T any](logger *StreamLogger[T]) LogFormatter { // shouldSampleQuery returns true if a query should be sampled based on queryLogSampleRate func shouldSampleQuery() bool { - sampleRate := queryLogSampleRate - if sampleRate <= 0 { + if queryLogSampleRate <= 0 { return false - } else if sampleRate > 1.0 { - sampleRate = 1.0 + } else if queryLogSampleRate >= 1.0 { + return true } - return rand.Float64() <= sampleRate + return rand.Float64() <= queryLogSampleRate } // ShouldEmitLog returns whether the log with the given SQL query