Skip to content

Commit

Permalink
adhoc: add grace time to k6-backed checks (#908)
Browse files Browse the repository at this point in the history
  • Loading branch information
roobre authored Oct 8, 2024
1 parent 3051520 commit f6bbead
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions internal/adhoc/adhoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,23 @@ func (h *Handler) defaultRunnerFactory(ctx context.Context, req *sm.AdHocRequest
return nil, err
}

// Ad-hoc checks that rely on k6 runners need some grace time to give the runner time to communicate a timeout back
// to us, instead of both us and the runner timing out at the same time and missing the runner's response. We define
// that grace time to be 20 seconds, to be consistent with the grace time used for k6, non ad-hoc checks.
timeout := time.Duration(check.Timeout) * time.Millisecond
switch check.Type() {
case sm.CheckTypeMultiHttp, sm.CheckTypeScripted, sm.CheckTypeBrowser:
const k6AdhocGraceTime = 20 * time.Second
timeout += k6AdhocGraceTime
}

return &runner{
logger: h.logger,
prober: p,
id: req.AdHocCheck.Id,
target: target,
probe: h.probe.Name,
timeout: time.Duration(req.AdHocCheck.Timeout) * time.Millisecond,
timeout: timeout,
}, nil
}

Expand Down Expand Up @@ -531,8 +541,10 @@ func (r *runner) Run(ctx context.Context, tenantId model.GlobalID, publisher pus
Msg("ad-hoc result sent to publisher")
}

type TimeSeries = []prompb.TimeSeries
type Streams = []logproto.Stream
type (
TimeSeries = []prompb.TimeSeries
Streams = []logproto.Stream
)

type adhocData struct {
tenantId model.GlobalID
Expand Down

0 comments on commit f6bbead

Please sign in to comment.