(inspector *asynq.Inspector, cfg benchmarkConfig)
| 242 | } |
| 243 | |
| 244 | func takeSnapshot(inspector *asynq.Inspector, cfg benchmarkConfig) (snapshot, error) { |
| 245 | queueNames, err := resolveQueueNames(inspector, cfg) |
| 246 | if err != nil { |
| 247 | return snapshot{}, err |
| 248 | } |
| 249 | |
| 250 | sort.Strings(queueNames) |
| 251 | |
| 252 | snap := snapshot{ |
| 253 | timestamp: time.Now().UTC(), |
| 254 | queueNames: queueNames, |
| 255 | } |
| 256 | |
| 257 | for _, name := range queueNames { |
| 258 | info, err := inspector.GetQueueInfo(name) |
| 259 | if err != nil { |
| 260 | return snapshot{}, fmt.Errorf("queue %s: %w", name, err) |
| 261 | } |
| 262 | |
| 263 | snap.pending += info.Pending |
| 264 | snap.active += info.Active |
| 265 | snap.scheduled += info.Scheduled |
| 266 | snap.retry += info.Retry |
| 267 | snap.aggregating += info.Aggregating |
| 268 | snap.archived += info.Archived |
| 269 | snap.size += info.Size |
| 270 | snap.processedTotal += info.ProcessedTotal |
| 271 | snap.failedTotal += info.FailedTotal |
| 272 | if latencyMs := float64(info.Latency.Milliseconds()); latencyMs > snap.latencyMs { |
| 273 | snap.latencyMs = latencyMs |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | return snap, nil |
| 278 | } |
| 279 | |
| 280 | func resolveQueueNames(inspector *asynq.Inspector, cfg benchmarkConfig) ([]string, error) { |
| 281 | names := make(map[string]struct{}) |
no test coverage detected