File tree 3 files changed +18
-1
lines changed
3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ require (
138
138
golang.org/x/exp v0.0.0-20221106115401-f9659909a136 // indirect
139
139
golang.org/x/sync v0.1.0 // indirect
140
140
golang.org/x/text v0.7.0 // indirect
141
- golang.org/x/time v0.2 .0 // indirect
141
+ golang.org/x/time v0.3 .0 // indirect
142
142
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
143
143
google.golang.org/grpc v1.53.0 // indirect
144
144
google.golang.org/protobuf v1.28.1 // indirect
Original file line number Diff line number Diff line change @@ -1211,6 +1211,8 @@ golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxb
1211
1211
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e /go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ =
1212
1212
golang.org/x/time v0.2.0 h1:52I/1L54xyEQAYdtcSuxtiT84KGYTBGXwayxmIpNJhE =
1213
1213
golang.org/x/time v0.2.0 /go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ =
1214
+ golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4 =
1215
+ golang.org/x/time v0.3.0 /go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ =
1214
1216
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635 /go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ =
1215
1217
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e /go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ =
1216
1218
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563 /go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ =
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
11
11
"github.com/prometheus/client_golang/prometheus/promhttp"
12
12
"golang.org/x/mod/semver"
13
13
"golang.org/x/sys/unix"
14
+ "golang.org/x/time/rate"
14
15
"k8s.io/klog/v2"
15
16
"net/http"
16
17
_ "net/http/pprof"
@@ -74,6 +75,9 @@ func machineID() string {
74
75
}
75
76
76
77
func main () {
78
+ klog .LogToStderr (false )
79
+ klog .SetOutput (& RateLimitedLogOutput {limiter : rate .NewLimiter (10 , 100 )})
80
+
77
81
klog .Infoln ("agent version:" , version )
78
82
79
83
hostname , kv , err := uname ()
@@ -128,3 +132,14 @@ type logger struct{}
128
132
func (l logger ) Println (v ... interface {}) {
129
133
klog .Errorln (v ... )
130
134
}
135
+
136
+ type RateLimitedLogOutput struct {
137
+ limiter * rate.Limiter
138
+ }
139
+
140
+ func (o * RateLimitedLogOutput ) Write (data []byte ) (int , error ) {
141
+ if ! o .limiter .Allow () {
142
+ return len (data ), nil
143
+ }
144
+ return os .Stderr .Write (data )
145
+ }
You can’t perform that action at this time.
0 commit comments