[DRAFT] feat(edge): strengthen edge reporter with metrics, backoff, structured logging - #33
Closed
tanmayxchoudhary wants to merge 2 commits into
Closed
Conversation
…d logging, and comprehensive tests Differentiators vs competing PRs (Clawland-AI#20, Clawland-AI#25, Clawland-AI#28, Clawland-AI#31): - In-process Prometheus-friendly metrics (expvar) tracking deliveries, failures, retries, queue depth - Exponential backoff with ±50% jitter for failed deliveries - Structured logging via pkg/logger (component, fields, levels) - Context-aware HTTP with timeout propagation - Separate heartbeat and status reporting loops - Async event queue with bounded worker pool and graceful drain - Race-condition-tested concurrency safety (-race clean) - Deterministic clock injection for testable timestamps - Full httptest coverage: registration, heartbeat, status, events, queueing, auth headers, X-Clawland-Node-ID, endpoint normalization, failure details, retries, timeouts, idempotent stop, concurrent access, metrics verification - Also fixes pkg/gene/selector.go tie-breaker for deterministic ordering Closes Clawland-AI#24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the Edge Reporter Module from #24 with a differentiated approach focusing on observability, reliability, and test coverage.
What was implemented
pkg/edge/config.goStatusInterval,MaxRetries,RetryBaseDelay,EventQueueSize,EventWorkersfields for fine-grained reporter controlDefaultConfig()with sensible defaultspkg/edge/metrics.go(NEW)expvar(exported asedgereporter)pkg/edge/reporter.go(Rewritten)pkg/loggerwith component prefix and key-value fieldsQueueEvent()WithClock()optionWithHeartbeatHook()/WithStatusHook()StartHeartbeat()aliassync.RWMutexforGeneStatsProviderpkg/gene/selector.goHow this differs from the 4 existing competing PRs
Test Results
Files Changed
pkg/edge/config.go— extended config with new reporter fieldspkg/edge/metrics.go— NEW expvar-based metrics collectorpkg/edge/reporter.go— full rewrite with differentiated featurespkg/edge/reporter_test.go— NEW 29 tests covering all paths (registration, heartbeat, status, events, queueing, auth headers, endpoint normalization, failure details, retries, timeouts, idempotent stop, concurrent access, metrics)pkg/gene/selector.go— deterministic tie-breaker fixCloses #24