File tree Expand file tree Collapse file tree 2 files changed +0
-29
lines changed Expand file tree Collapse file tree 2 files changed +0
-29
lines changed Original file line number Diff line number Diff line change 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.
183173func (l * Logger ) NewContext () * Context {
184174 c := newContext (l .values )
Original file line number Diff line number Diff 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-
217198func setenv (t * testing.T , env map [string ]string ) {
218199 for k , v := range env {
219200 err := os .Setenv (k , v )
You can’t perform that action at this time.
0 commit comments