Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <[email protected]>
  • Loading branch information
timvaillancourt committed May 11, 2024
1 parent 836058d commit e8aa18f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions go/streamlog/streamlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e8aa18f

Please sign in to comment.