Skip to content

Commit b073f6c

Browse files
committed
pass default period to define what means skipper to be slow
Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
1 parent 6e7c62a commit b073f6c

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

proxy/proxy.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ type Params struct {
368368
// FlightRecorderTargetURL is the target to write the trace
369369
// to. Supported targets are http URL and file URL.
370370
FlightRecorderTargetURL string
371+
372+
// FlightRecorderPeriod is the time.Duration that is used for
373+
// a slow skipper. If skipper is detected to be slow it tries
374+
// to write out a trace as configured by the FlightRecorderTargetURL.
375+
FlightRecorderPeriod time.Duration
371376
}
372377

373378
type (
@@ -464,6 +469,7 @@ type Proxy struct {
464469
onPanicSometimes rate.Sometimes
465470
flightRecorder *trace.FlightRecorder
466471
flightRecorderURL *url.URL
472+
flightRecorderPeriod time.Duration
467473
}
468474

469475
// proxyError is used to wrap errors during proxying and to indicate
@@ -896,6 +902,7 @@ func WithParams(p Params) *Proxy {
896902
onPanicSometimes: rate.Sometimes{First: 3, Interval: 1 * time.Minute},
897903
flightRecorder: p.FlightRecorder,
898904
flightRecorderURL: frURL,
905+
flightRecorderPeriod: p.FlightRecorderPeriod,
899906
}
900907
}
901908

@@ -904,7 +911,7 @@ func (p *Proxy) writeTraceIfTooSlow(ctx *context) {
904911
return
905912
}
906913

907-
var d time.Duration
914+
d := p.flightRecorderPeriod
908915
if e, ok := ctx.StateBag()[filters.TraceName]; ok {
909916
d = e.(time.Duration)
910917
}

skipper.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,18 +2050,20 @@ func run(o Options, sig chan os.Signal, idleConnsCH chan struct{}) error {
20502050
routing := routing.New(ro)
20512051
defer routing.Close()
20522052

2053+
frPeriod := defaultFlightRecorderPeriod
20532054
var fr *trace.FlightRecorder
20542055
if o.FlightRecorderTargetURL != "" {
20552056
fr = trace.NewFlightRecorder()
20562057

20572058
if o.FlightRecorderPeriod != 0 {
2058-
fr.SetPeriod(o.FlightRecorderPeriod)
2059-
} else {
2060-
fr.SetPeriod(defaultFlightRecorderPeriod)
2059+
frPeriod = o.FlightRecorderPeriod
20612060
}
2061+
fr.SetPeriod(frPeriod)
20622062

2063+
frSize := defaultFlightRecorderSize
20632064
if o.FlightRecorderSize != 0 {
20642065
fr.SetSize(o.FlightRecorderSize)
2066+
frSize = o.FlightRecorderSize
20652067
} else {
20662068
fr.SetSize(defaultFlightRecorderSize)
20672069
}
@@ -2071,9 +2073,10 @@ func run(o Options, sig chan os.Signal, idleConnsCH chan struct{}) error {
20712073
log.Errorf("Failed to start FlightRecorder: %v", err)
20722074
fr.Stop()
20732075
fr = nil
2076+
} else {
2077+
log.Infof("FlightRecorder started with config (%s, %d) target: %s", frPeriod, frSize, o.FlightRecorderTargetURL)
20742078
}
20752079
}
2076-
log.Infof("FlightRecorder: %v", fr)
20772080

20782081
proxyFlags := proxy.Flags(o.ProxyOptions) | o.ProxyFlags
20792082
proxyParams := proxy.Params{
@@ -2105,6 +2108,7 @@ func run(o Options, sig chan os.Signal, idleConnsCH chan struct{}) error {
21052108
PassiveHealthCheck: passiveHealthCheck,
21062109
FlightRecorder: fr,
21072110
FlightRecorderTargetURL: o.FlightRecorderTargetURL,
2111+
FlightRecorderPeriod: frPeriod,
21082112
}
21092113

21102114
if o.EnableBreakers || len(o.BreakerSettings) > 0 {

0 commit comments

Comments
 (0)