Add Prometheus metrics and /metrics endpoint per leanMetrics spec#444
Open
ch4r10t33r wants to merge 4 commits intoleanEthereum:mainfrom
Open
Add Prometheus metrics and /metrics endpoint per leanMetrics spec#444ch4r10t33r wants to merge 4 commits intoleanEthereum:mainfrom
ch4r10t33r wants to merge 4 commits intoleanEthereum:mainfrom
Conversation
…ockLookup class - Convert BlockLookup from type alias to proper dict subclass with ancestors() generator and reorg_depth() method - Replace module-level mutable globals in metrics registry with MetricsRegistry class using null object pattern (_NoOpMetric stubs) - Eliminate all try/except ImportError guards and noqa: I001 suppressions - Move _record_metrics_after_block into Store._record_metrics method - Remove unused old_safe parameter from metrics recording - Delete init_metrics backward compat wrapper, use metrics.init() directly - Add comprehensive tests for BlockLookup (20 tests) and _record_metrics (12 tests) - Update all consumers (store, sync/service, node, __main__) to use qualified metrics access Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dict.__or__ returns a plain dict, losing the BlockLookup type when
used in Pydantic model_copy(update={"blocks": self.blocks | {...}}).
Override returns BlockLookup so reorg_depth and ancestors remain
available after store updates.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 the metrics defined in leanEthereum/leanMetrics:
lean_spec.subspecs.metrics): Prometheus counters, gauges, and histograms for node info, head/safe/justified/finalized slots, state transition and attestation validation timing, reorgs, attestation validity, current slot, connected peers, and validator count./metricsendpoint on the existing API server (default port 5052, configurable via--api-port, use0to disable).Dependencies:
prometheus-clientadded; metrics are optional (guarded by import and runtime flag) so the node runs without them if unavailable.