Harden redis metrics collection against transient errors - #5131
Harden redis metrics collection against transient errors#5131nikola-jokic wants to merge 2 commits into
Conversation
|
Greptile SummaryThe PR makes Redis stream metrics collection resilient to vanished streams and transient scan failures while retaining the last successful data snapshot.
Confidence Score: 4/5The PR is not yet safe to merge because the cancellation test remains incompatible with the collector’s failure-snapshot behavior. A cancelled first collection now publishes error telemetry through the atomic snapshot, while Files Needing Attention: internal/eventingester/metrics/redis/collector.go, internal/eventingester/metrics/redis/collector_test.go
|
| Filename | Overview |
|---|---|
| internal/eventingester/metrics/redis/collector.go | Adds retry handling and stale-snapshot publication, but its first-failure behavior remains inconsistent with the cancellation test. |
| internal/eventingester/metrics/redis/collector_test.go | Adds coverage for retries and stale metrics, while the cancellation assertion still conflicts with the collector’s published failure snapshot. |
| internal/eventingester/configuration/validation.go | Validates negative and inconsistent retry backoff values against the collector’s effective defaults. |
| internal/common/config/validation.go | Safely formats validator errors while passing through ordinary errors without a panic. |
| internal/eventingester/repository/scanner.go | Treats Redis missing-key responses as vanished streams and continues collecting remaining stream metrics. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Start collection cycle] --> B[Scan Redis with attempt timeout]
B -->|Transient error| C{Retries remaining?}
C -->|Yes| D[Wait with bounded exponential backoff]
D --> B
C -->|No| E[Increment failure telemetry]
B -->|Success| F[Build current metrics]
E --> G[Publish stale data with current failure telemetry]
F --> H[Publish new atomic snapshot]
B -->|Vanished stream| I[Skip missing key]
I --> B
Reviews (10): Last reviewed commit: "trim down validations" | Re-trigger Greptile
| // Collect snapshot with error metrics | ||
| c.collectSnapshot() | ||
| c.collectionDuration.WithLabelValues(collectionStatusError).Observe(time.Since(start).Seconds()) | ||
| c.collectSnapshot() // Update snapshot with self-monitoring metrics even on error |
There was a problem hiding this comment.
When the first collection attempt is cancelled, this call publishes a non-empty snapshot containing errorsTotal and the error-labelled collectionDuration, but TestCollect_ContextCancellation requires the collected metrics to remain empty, causing the test suite to fail.
Knowledge Base Used: Event store and ingestion
975d726 to
570cedc
Compare
570cedc to
fbfcfdf
Compare
What type of PR is this?
Fix
What this PR does / why we need it