Skip to content

Commit 1259b6e

Browse files
committed
Sampling doesn't belong here
1 parent 7642820 commit 1259b6e

File tree

2 files changed

+0
-29
lines changed

2 files changed

+0
-29
lines changed

emf/logger.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"encoding/json"
55
"fmt"
66
"io"
7-
"math/rand"
87
"os"
98
"strings"
109
"time"
@@ -170,15 +169,6 @@ func (l *Logger) Log() {
170169
_, _ = fmt.Fprintln(l.out, string(buf))
171170
}
172171

173-
// LogSampled samples Log calls based on a rate.
174-
// Ex. rate of 0.7 means Log will be called 70% of a time.
175-
func (l *Logger) LogSampled(rate float64) {
176-
rand.Seed(time.Now().UnixNano())
177-
if rand.Float64() < rate {
178-
l.Log()
179-
}
180-
}
181-
182172
// NewContext creates new context for given logger.
183173
func (l *Logger) NewContext() *Context {
184174
c := newContext(l.values)

emf/logger_test.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -195,25 +195,6 @@ func TestEmf(t *testing.T) {
195195
}
196196
}
197197

198-
func TestLogger_LogSampled(t *testing.T) {
199-
200-
t.Run("never", func(t *testing.T) {
201-
var buf bytes.Buffer
202-
emf.NewFor(&buf).Metric("foo", 1).LogSampled(0)
203-
if buf.Len() > 0 {
204-
t.Fatal("should be empty")
205-
}
206-
})
207-
208-
t.Run("always", func(t *testing.T) {
209-
var buf bytes.Buffer
210-
emf.NewFor(&buf).Metric("foo", 1).LogSampled(100)
211-
if buf.Len() == 0 {
212-
t.Fatal("should not be empty")
213-
}
214-
})
215-
}
216-
217198
func setenv(t *testing.T, env map[string]string) {
218199
for k, v := range env {
219200
err := os.Setenv(k, v)

0 commit comments

Comments
 (0)