UpstreamRPCProviderStatistics
Documentation for eth_defi.provider.rpc_proxy.UpstreamRPCProviderStatistics Python class.
- class UpstreamRPCProviderStatistics
Bases:
objectPer-provider statistics collected during proxy operation.
Tracks request counts, failure counts, and method-level breakdowns for each upstream RPC provider. Instances are keyed by provider URL in
RPCProxy.provider_stats.Attributes summary
Upstream RPC URL (with API keys stripped for safe logging)
Total number of requests forwarded to this provider
Total number of failed requests (timeouts, HTTP errors, RPC errors)
Timestamp of the last failure (naive UTC), or
Noneif no failuresBreakdown of requests by JSON-RPC method name.
Breakdown of failures by JSON-RPC method name
List of error replies received from this provider.
Methods summary
__init__(url[, request_count, ...])record_failure(method, error_summary[, ...])Record a failed request to this provider.
record_request(method)Record a request being sent to this provider.
- url: str
Upstream RPC URL (with API keys stripped for safe logging)
- request_count: int
Total number of requests forwarded to this provider
- failure_count: int
Total number of failed requests (timeouts, HTTP errors, RPC errors)
- last_failure: Optional[datetime.datetime]
Timestamp of the last failure (naive UTC), or
Noneif no failures
- method_counts: dict[str, int]
Breakdown of requests by JSON-RPC method name. e.g.
{"eth_getBlockByNumber": 42, "eth_getBalance": 15}
- error_replies: list[dict]
List of error replies received from this provider. Each entry is a dict with keys:
"timestamp"(naive UTC),"method"(JSON-RPC method),"http_status"(int or None),"error"(str summary — exception message, HTTP status text, or JSON-RPC error message). Capped atDEFAULT_MAX_ERROR_REPLIESto avoid unbounded growth.
- record_request(method)
Record a request being sent to this provider.
- Parameters
method (str) –
- Return type
None
- record_failure(method, error_summary, http_status=None, max_error_replies=100)
Record a failed request to this provider.
- __init__(url, request_count=0, failure_count=0, last_failure=None, method_counts=<factory>, method_failure_counts=<factory>, error_replies=<factory>, _lock=<factory>)