feat: add metrics, health endpoint, and structured logging (#441)#447
Open
morelucks wants to merge 1 commit intoleanEthereum:mainfrom
Open
feat: add metrics, health endpoint, and structured logging (#441)#447morelucks wants to merge 1 commit intoleanEthereum:mainfrom
morelucks wants to merge 1 commit intoleanEthereum:mainfrom
Conversation
…eum#441) - Prometheus metrics: slot_current, epoch_current, peers_connected, blocks_imported_total, attestations_processed_total, sync_distance, process_start_time_seconds exposed via /metrics endpoint - Health endpoint: GET /health returns {status, slot, synced} with 200 when synced, 503 otherwise (K8s readiness probe compatible) - Structured JSON logging via --log-format json with slot, epoch, peer_id fields; log level via --log-level / LEANSPEC_LOG_LEVEL - CLI: --metrics-port flag to enable metrics/health server - Docker: EXPOSE 8008, docker-compose with Prometheus + Grafana - Docs: DOCKER_QUICKSTART.md updated with observability section - Grafana dashboard JSON included in observability/
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.
Implements #441 — adds Prometheus metrics, a health endpoint, and structured JSON logging to
leanspec-node.Changes
Prometheus Metrics (
/metrics)Exposes 7 metrics in Prometheus text exposition format:
leanspec_slot_currentleanspec_epoch_currentslot // JUSTIFICATION_LOOKBACK_SLOTSleanspec_peers_connectedleanspec_blocks_imported_totalSyncService._process_block_wrapperleanspec_attestations_processed_totalleanspec_sync_distanceleanspec_process_start_time_secondsEach Metrics instance uses its own
CollectorRegistryto avoid global state collisions in tests.Health Endpoint (
GET /health)Returns
{"status": "ok", "slot": N, "synced": bool}with:Sync status determined by
SyncService.state.is_synced— suitable for Docker/Kubernetes readiness probes.Structured Logging
--log-format jsonenables JSON output viapython-json-loggerslot,epoch,peers,peer_idas structured fields--log-levelCLI flag (defaults toLEANSPEC_LOG_LEVELenv var)Docker & Deployment
EXPOSE 8008in Dockerfile node stageCLI Flags
--metrics-port PORT--log-format {text,json}--log-level LEVELLEANSPEC_LOG_LEVEL)Acceptance Criteria
/metricsendpoint returns valid Prometheus text exposition format/healthendpoint returns correct synced field based on sync state--log-format jsonis set--metrics-portCLI flagcloses #441