tsweb: switch to fastuuid for request ID generation

Request ID generation appears prominently in some services cumulative
allocation rate, and while this does not eradicate this issue (the API
still makes UUID objects), it does improve the overhead of this API and
reduce the amount of garbage that it produces.

Updates tailscale/corp#18266
Updates tailscale/corp#19054

Signed-off-by: James Tucker <james@tailscale.com>
This commit is contained in:
James Tucker
2024-04-09 13:06:48 -07:00
committed by James Tucker
parent d0f3fa7d7e
commit 8fa3026614
3 changed files with 8 additions and 4 deletions

View File

@@ -7,8 +7,8 @@ import (
"context"
"net/http"
"github.com/google/uuid"
"tailscale.com/util/ctxkey"
"tailscale.com/util/fastuuid"
)
// RequestID is an opaque identifier for a HTTP request, used to correlate
@@ -44,7 +44,7 @@ func GenerateRequestID() RequestID {
// REQ-1 indicates the version of the RequestID pattern. It is
// currently arbitrary but allows for forward compatible
// transitions if needed.
return RequestID("REQ-1" + uuid.NewString())
return RequestID("REQ-1" + fastuuid.NewUUID().String())
}
// SetRequestID is an HTTP middleware that injects a RequestID in the