Skip to content

Commit

Permalink
fix response time metric
Browse files Browse the repository at this point in the history
Signed-off-by: hfuss <hayden.fuss@kaleido.io>
  • Loading branch information
onelapahead committed Dec 13, 2024
1 parent 712aa96 commit 8008940
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pkg/ffresty/ffresty.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ import (
)

const (
metricsHTTPResponsesTotal = "http_responses_total"
metricsNetworkErrorsTotal = "network_errors_total"
metricsHTTPRequestBodySize = "http_request_body_size_bytes"
metricsHTTPResponseTime = "http_response_time_seconds"
metricsHTTPResponsesTotal = "http_responses_total"
metricsNetworkErrorsTotal = "network_errors_total"
metricsHTTPResponseTime = "http_response_time_seconds"
)

type retryCtxKey struct{}
Expand Down Expand Up @@ -256,6 +255,10 @@ func NewWithConfig(ctx context.Context, ffrestyConfig Config) (client *resty.Cli
}
}
rCtx := req.Context()
// Record host in context to avoid redundant parses in hooks
u, _ := url.Parse(req.URL)
host := u.Host
rCtx = context.WithValue(rCtx, hostCtxKey{}, host)
rc := rCtx.Value(retryCtxKey{})
if rc == nil {
// First attempt
Expand All @@ -266,10 +269,6 @@ func NewWithConfig(ctx context.Context, ffrestyConfig Config) (client *resty.Cli
rCtx = context.WithValue(rCtx, retryCtxKey{}, r)
// Create a request logger from the root logger passed into the client
rCtx = log.WithLogField(rCtx, "breq", r.id)
// Record host in context to avoid redundant parses in hooks
u, _ := url.Parse(req.URL)
host := u.Host
rCtx = context.WithValue(rCtx, hostCtxKey{}, host)
req.SetContext(rCtx)
}

Expand Down

0 comments on commit 8008940

Please sign in to comment.