Skip to content

Commit

Permalink
fix: handling of response-times and metric timestamps (separate betwe…
Browse files Browse the repository at this point in the history
…en request written and request started)
  • Loading branch information
ReuDa committed Nov 15, 2023
1 parent e29e89f commit d7a9cae
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions exthttpcheck/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,13 @@ func requestWorker(executionRunData *ExecutionRunData, state *HTTPCheckState, ch
for range executionRunData.jobs {
if !checkEnded(executionRunData, state) {
var started = time.Now()
var requestWritten time.Time
var ended time.Time

// see seems to break a configured proxy. maybe we can use it in the future and configure the proxy here
trace := &httptrace.ClientTrace{
WroteRequest: func(info httptrace.WroteRequestInfo) {
started = time.Now()
requestWritten = time.Now()
},
GotFirstResponseByte: func() {
ended = time.Now()
Expand Down Expand Up @@ -248,7 +249,7 @@ func requestWorker(executionRunData *ExecutionRunData, state *HTTPCheckState, ch
metric := action_kit_api.Metric{
Name: extutil.Ptr("response_time"),
Metric: metricMap,
Value: float64(ended.Sub(started).Milliseconds()),
Value: float64(ended.Sub(requestWritten).Milliseconds()),
Timestamp: ended,
}
executionRunData.metrics <- metric
Expand Down

0 comments on commit d7a9cae

Please sign in to comment.