Merge pull request #31175 from cuiweixie/atomic.Uint64

pkg/register: refactor to use atomic.Uint64
pull/12960/merge
Robert Sirchia 2 weeks ago committed by GitHub
commit fc5bd02a1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -32,7 +32,7 @@ import (
var ( var (
// requestCount records the number of logged request-response pairs and will // requestCount records the number of logged request-response pairs and will
// be used as the unique id for the next pair. // be used as the unique id for the next pair.
requestCount uint64 requestCount atomic.Uint64
// toScrub is a set of headers that should be scrubbed from the log. // toScrub is a set of headers that should be scrubbed from the log.
toScrub = []string{ toScrub = []string{
@ -79,7 +79,7 @@ func NewTransport(debug bool) *retry.Transport {
// RoundTrip calls base round trip while keeping track of the current request. // RoundTrip calls base round trip while keeping track of the current request.
func (t *LoggingTransport) RoundTrip(req *http.Request) (resp *http.Response, err error) { func (t *LoggingTransport) RoundTrip(req *http.Request) (resp *http.Response, err error) {
id := atomic.AddUint64(&requestCount, 1) - 1 id := requestCount.Add(1) - 1
slog.Debug(req.Method, "id", id, "url", req.URL, "header", logHeader(req.Header)) slog.Debug(req.Method, "id", id, "url", req.URL, "header", logHeader(req.Header))
resp, err = t.RoundTripper.RoundTrip(req) resp, err = t.RoundTripper.RoundTrip(req)

Loading…
Cancel
Save