From b598c162a9780a21240ac5641c0b2f494a3f4b60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E6=B3=93=E9=93=AE?= Date: Tue, 15 Jul 2025 20:18:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9Elogid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uixt/driver_session.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/uixt/driver_session.go b/uixt/driver_session.go index 89dd47d6..ab837c9a 100644 --- a/uixt/driver_session.go +++ b/uixt/driver_session.go @@ -14,6 +14,7 @@ import ( "strings" "time" + "github.com/google/uuid" "github.com/pkg/errors" "github.com/rs/zerolog" "github.com/rs/zerolog/log" @@ -233,6 +234,7 @@ func (s *DriverSession) RequestWithRetry(method string, urlStr string, rawBody [ func (s *DriverSession) Request(method string, urlStr string, rawBody []byte, opts ...option.ActionOption) ( rawResp DriverRawResponse, err error, ) { + logid := uuid.New().String() timeout := s.timeout options := option.NewActionOptions(opts...) if options.Timeout > 0 { @@ -264,7 +266,7 @@ func (s *DriverSession) Request(method string, urlStr string, rawBody []byte, op logger = log.Debug().Bool("success", true) } - logger = logger.Str("request_method", method).Str("request_url", rawURL). + logger = logger.Str("logid", logid).Str("request_method", method).Str("request_url", rawURL). Str("request_body", string(rawBody)) if !driverResult.RequestTime.IsZero() { logger = logger.Int64("request_time", driverResult.RequestTime.UnixMilli()) @@ -287,6 +289,8 @@ func (s *DriverSession) Request(method string, urlStr string, rawBody []byte, op } req.Header.Set("Content-Type", "application/json;charset=UTF-8") req.Header.Set("Accept", "application/json") + req.Header.Set("X-HTTP-Request-ID", logid) + req.Header.Set("logid", logid) driverResult.RequestTime = time.Now() var resp *http.Response