@@ -13,42 +13,42 @@ type ConcurrencyHandler struct {
13
13
sem chan struct {}
14
14
logger * zap.SugaredLogger
15
15
AcquisitionTimes []time.Duration
16
- lock sync.Mutex
17
16
lastTokenAcquisitionTime time.Time
18
17
Metrics * ConcurrencyMetrics
18
+ sync.Mutex
19
19
}
20
20
21
21
// ConcurrencyMetrics captures various metrics related to managing concurrency for the client's interactions with the API.
22
22
type ConcurrencyMetrics struct {
23
- TotalRequests int64 // Total number of requests made
24
- TotalRetries int64 // Total number of retry attempts
25
- TotalRateLimitErrors int64 // Total number of rate limit errors encountered
26
- PermitWaitTime time.Duration // Total time spent waiting for tokens
27
- TTFB struct { // Metrics related to Time to First Byte (TTFB)
28
- Total time.Duration // Total Time to First Byte (TTFB) for all requests
29
- Count int64 // Count of requests used for calculating TTFB
30
- Lock sync.Mutex // Lock for TTFB metrics
23
+ TotalRequests int64
24
+ TotalRetries int64
25
+ TotalRateLimitErrors int64
26
+ PermitWaitTime time.Duration
27
+ sync.Mutex
28
+ TTFB struct {
29
+ Total time.Duration
30
+ Count int64
31
+ sync.Mutex
31
32
}
32
- Throughput struct { // Metrics related to network throughput
33
- Total float64 // Total network throughput for all requests
34
- Count int64 // Count of requests used for calculating throughput
35
- Lock sync.Mutex // Lock for throughput metrics/
33
+ Throughput struct {
34
+ Total float64
35
+ Count int64
36
+ sync.Mutex
36
37
}
37
- ResponseTimeVariability struct { // Metrics related to response time variability
38
- Total time.Duration // Total response time for all requests
39
- Average time.Duration // Average response time across all requests
40
- Variance float64 // Variance of response times
41
- Count int64 // Count of responses used for calculating response time variability
42
- Lock sync.Mutex // Lock for response time variability metrics
43
- StdDevThreshold float64 // Maximum acceptable standard deviation for adjusting concurrency
44
- DebounceScaleDownCount int // Counter to manage scale down actions after consecutive triggers
45
- DebounceScaleUpCount int // Counter to manage scale up actions after consecutive triggers
38
+ ResponseTimeVariability struct {
39
+ Total time.Duration
40
+ Average time.Duration
41
+ Variance float64
42
+ Count int64
43
+ sync.Mutex
44
+ StdDevThreshold float64
45
+ DebounceScaleDownCount int
46
+ DebounceScaleUpCount int
46
47
}
47
48
ResponseCodeMetrics struct {
48
- ErrorRate float64 // Error rate calculated as (TotalRateLimitErrors + 5xxErrors) / TotalRequests
49
- Lock sync.Mutex // Lock for response code metrics
49
+ ErrorRate float64
50
+ sync.Mutex
50
51
}
51
- Lock sync.Mutex // Lock for overall metrics fields
52
52
}
53
53
54
54
// NewConcurrencyHandler initializes a new ConcurrencyHandler with the given
0 commit comments