From 04cb1bad672e5d10453bea42d0fcaee5dae8df63 Mon Sep 17 00:00:00 2001 From: cuiweixie Date: Thu, 21 Aug 2025 19:44:33 +0800 Subject: [PATCH] pkg/register: refactor to use atomic.Uint64 Signed-off-by: cuiweixie --- pkg/registry/transport.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/registry/transport.go b/pkg/registry/transport.go index a82229e2f..9d6a37326 100644 --- a/pkg/registry/transport.go +++ b/pkg/registry/transport.go @@ -32,7 +32,7 @@ import ( var ( // requestCount records the number of logged request-response pairs and will // 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 = []string{ @@ -79,7 +79,7 @@ func NewTransport(debug bool) *retry.Transport { // RoundTrip calls base round trip while keeping track of the current request. 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)) resp, err = t.RoundTripper.RoundTrip(req)