@@ -27,12 +27,33 @@ type ConcurrencyHandler struct {
2727
2828// ConcurrencyMetrics captures various metrics related to managing concurrency for the client's interactions with the API.
2929type ConcurrencyMetrics struct {
30- TotalRequests int64
31- TotalRetries int64
32- TotalRateLimitErrors int64
33- TotalResponseTime time.Duration
34- TokenWaitTime time.Duration
35- Lock sync.Mutex // Protects performance metrics fields
30+ TotalRequests int64 // Total number of requests made
31+ TotalRetries int64 // Total number of retry attempts
32+ TotalRateLimitErrors int64 // Total number of rate limit errors encountered
33+ TokenWaitTime time.Duration // Total time spent waiting for tokens
34+ TTFB struct { // Metrics related to Time to First Byte (TTFB)
35+ Total time.Duration // Total Time to First Byte (TTFB) for all requests
36+ Count int64 // Count of requests used for calculating TTFB
37+ Lock sync.Mutex // Lock for TTFB metrics
38+ }
39+ Throughput struct { // Metrics related to network throughput
40+ Total float64 // Total network throughput for all requests
41+ Count int64 // Count of requests used for calculating throughput
42+ Lock sync.Mutex // Lock for throughput metrics/
43+ }
44+ ResponseTimeVariability struct { // Metrics related to response time variability
45+ Total time.Duration // Total response time for all requests
46+ Average time.Duration // Average response time across all requests
47+ Variance float64 // Variance of response times
48+ Count int64 // Count of responses used for calculating response time variability
49+ Lock sync.Mutex // Lock for response time variability metrics
50+ StdDevThreshold float64 // Maximum acceptable standard deviation for adjusting concurrency
51+ }
52+ ResponseCodeMetrics struct {
53+ ErrorRate float64 // Error rate calculated as (TotalRateLimitErrors + 5xxErrors) / TotalRequests
54+ Lock sync.Mutex // Lock for response code metrics
55+ }
56+ Lock sync.Mutex // Lock for overall metrics fields
3657}
3758
3859// NewConcurrencyHandler initializes a new ConcurrencyHandler with the given
0 commit comments