You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: httpclient/httpclient_request.go
+79-33Lines changed: 79 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -14,20 +14,40 @@ import (
14
14
"go.uber.org/zap"
15
15
)
16
16
17
-
// updatePerformanceMetrics updates the client's performance metrics by recording the duration
18
-
// of the HTTP request and incrementing the total request count. This function is thread-safe
19
-
// and uses a mutex to synchronize updates to the performance metrics.
17
+
// executeHTTPRequest sends an HTTP request using the client's HTTP client. It logs the request and error details, if any, using structured logging with zap fields.
20
18
//
21
19
// Parameters:
22
-
// - duration: The time duration it took for an HTTP request to complete.
20
+
// - req: The *http.Request object that contains all the details of the HTTP request to be sent.
21
+
// - log: An instance of a logger (conforming to the logger.Logger interface) used for logging the request details and any errors.
22
+
// - method: The HTTP method used for the request, used for logging.
23
+
// - endpoint: The API endpoint the request is being sent to, used for logging.
23
24
//
24
-
// This function should be called after each HTTP request to keep track of the client's
// - *http.Response: The HTTP response from the server.
27
+
// - error: An error object if an error occurred while sending the request or nil if no error occurred.
28
+
//
29
+
// Usage:
30
+
// This function should be used whenever the client needs to send an HTTP request. It abstracts away the common logic of request execution and error handling, providing detailed logs for debugging and monitoring.
0 commit comments