Add metrics to all RPC {state_id} endpoints. (#6282)
This commit is contained in:
parent
d0400e408b
commit
0b8cb4efc4
|
@ -10,7 +10,7 @@
|
||||||
import
|
import
|
||||||
std/[typetraits, sequtils, sets],
|
std/[typetraits, sequtils, sets],
|
||||||
stew/[results, base10],
|
stew/[results, base10],
|
||||||
chronicles,
|
chronicles, metrics,
|
||||||
./rest_utils,
|
./rest_utils,
|
||||||
./state_ttl_cache,
|
./state_ttl_cache,
|
||||||
../beacon_node,
|
../beacon_node,
|
||||||
|
@ -179,7 +179,9 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
RestApiResponse.jsonError(Http404, StateNotFoundError)
|
RestApiResponse.jsonError(Http404, StateNotFoundError)
|
||||||
|
|
||||||
# https://ethereum.github.io/beacon-APIs/#/Beacon/getStateFork
|
# https://ethereum.github.io/beacon-APIs/#/Beacon/getStateFork
|
||||||
router.api2(MethodGet, "/eth/v1/beacon/states/{state_id}/fork") do (
|
router.metricsApi2(
|
||||||
|
MethodGet, "/eth/v1/beacon/states/{state_id}/fork",
|
||||||
|
{RestServerMetricsType.Status, Response}) do (
|
||||||
state_id: StateIdent) -> RestApiResponse:
|
state_id: StateIdent) -> RestApiResponse:
|
||||||
let
|
let
|
||||||
sid = state_id.valueOr:
|
sid = state_id.valueOr:
|
||||||
|
@ -210,8 +212,9 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
RestApiResponse.jsonError(Http404, StateNotFoundError)
|
RestApiResponse.jsonError(Http404, StateNotFoundError)
|
||||||
|
|
||||||
# https://ethereum.github.io/beacon-APIs/#/Beacon/getStateFinalityCheckpoints
|
# https://ethereum.github.io/beacon-APIs/#/Beacon/getStateFinalityCheckpoints
|
||||||
router.api2(MethodGet,
|
router.metricsApi2(
|
||||||
"/eth/v1/beacon/states/{state_id}/finality_checkpoints") do (
|
MethodGet, "/eth/v1/beacon/states/{state_id}/finality_checkpoints",
|
||||||
|
{RestServerMetricsType.Status, Response}) do (
|
||||||
state_id: StateIdent) -> RestApiResponse:
|
state_id: StateIdent) -> RestApiResponse:
|
||||||
let
|
let
|
||||||
sid = state_id.valueOr:
|
sid = state_id.valueOr:
|
||||||
|
@ -370,7 +373,9 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
RestApiResponse.jsonError(Http404, StateNotFoundError)
|
RestApiResponse.jsonError(Http404, StateNotFoundError)
|
||||||
|
|
||||||
# https://ethereum.github.io/beacon-APIs/#/Beacon/getStateValidators
|
# https://ethereum.github.io/beacon-APIs/#/Beacon/getStateValidators
|
||||||
router.api2(MethodGet, "/eth/v1/beacon/states/{state_id}/validators") do (
|
router.metricsApi2(
|
||||||
|
MethodGet, "/eth/v1/beacon/states/{state_id}/validators",
|
||||||
|
{RestServerMetricsType.Status, Response}) do (
|
||||||
state_id: StateIdent, id: seq[ValidatorIdent],
|
state_id: StateIdent, id: seq[ValidatorIdent],
|
||||||
status: seq[ValidatorFilter]) -> RestApiResponse:
|
status: seq[ValidatorFilter]) -> RestApiResponse:
|
||||||
let
|
let
|
||||||
|
@ -405,7 +410,9 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
getValidators(node, bslot, validatorsMask, validatorIds)
|
getValidators(node, bslot, validatorsMask, validatorIds)
|
||||||
|
|
||||||
# https://ethereum.github.io/beacon-APIs/#/Beacon/postStateValidators
|
# https://ethereum.github.io/beacon-APIs/#/Beacon/postStateValidators
|
||||||
router.api2(MethodPost, "/eth/v1/beacon/states/{state_id}/validators") do (
|
router.metricsApi2(
|
||||||
|
MethodPost, "/eth/v1/beacon/states/{state_id}/validators",
|
||||||
|
{RestServerMetricsType.Status, Response}) do (
|
||||||
state_id: StateIdent, contentBody: Option[ContentBody]) -> RestApiResponse:
|
state_id: StateIdent, contentBody: Option[ContentBody]) -> RestApiResponse:
|
||||||
let
|
let
|
||||||
(validatorIds, validatorsMask) =
|
(validatorIds, validatorsMask) =
|
||||||
|
@ -432,8 +439,9 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
getValidators(node, bslot, validatorsMask, validatorIds)
|
getValidators(node, bslot, validatorsMask, validatorIds)
|
||||||
|
|
||||||
# https://ethereum.github.io/beacon-APIs/#/Beacon/getStateValidator
|
# https://ethereum.github.io/beacon-APIs/#/Beacon/getStateValidator
|
||||||
router.api2(MethodGet,
|
router.metricsApi2(
|
||||||
"/eth/v1/beacon/states/{state_id}/validators/{validator_id}") do (
|
MethodGet, "/eth/v1/beacon/states/{state_id}/validators/{validator_id}",
|
||||||
|
{RestServerMetricsType.Status, Response}) do (
|
||||||
state_id: StateIdent, validator_id: ValidatorIdent) -> RestApiResponse:
|
state_id: StateIdent, validator_id: ValidatorIdent) -> RestApiResponse:
|
||||||
let
|
let
|
||||||
sid = state_id.valueOr:
|
sid = state_id.valueOr:
|
||||||
|
@ -498,8 +506,9 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
RestApiResponse.jsonError(Http404, StateNotFoundError)
|
RestApiResponse.jsonError(Http404, StateNotFoundError)
|
||||||
|
|
||||||
# https://ethereum.github.io/beacon-APIs/#/Beacon/getStateValidatorBalances
|
# https://ethereum.github.io/beacon-APIs/#/Beacon/getStateValidatorBalances
|
||||||
router.api2(MethodGet,
|
router.metricsApi2(
|
||||||
"/eth/v1/beacon/states/{state_id}/validator_balances") do (
|
MethodGet, "/eth/v1/beacon/states/{state_id}/validator_balances",
|
||||||
|
{RestServerMetricsType.Status, Response}) do (
|
||||||
state_id: StateIdent, id: seq[ValidatorIdent]) -> RestApiResponse:
|
state_id: StateIdent, id: seq[ValidatorIdent]) -> RestApiResponse:
|
||||||
let
|
let
|
||||||
sid = state_id.valueOr:
|
sid = state_id.valueOr:
|
||||||
|
@ -524,8 +533,9 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
getBalances(node, bslot, validatorIds)
|
getBalances(node, bslot, validatorIds)
|
||||||
|
|
||||||
# https://ethereum.github.io/beacon-APIs/#/Beacon/postStateValidatorBalances
|
# https://ethereum.github.io/beacon-APIs/#/Beacon/postStateValidatorBalances
|
||||||
router.api2(MethodPost,
|
router.metricsApi2(
|
||||||
"/eth/v1/beacon/states/{state_id}/validator_balances") do (
|
MethodPost, "/eth/v1/beacon/states/{state_id}/validator_balances",
|
||||||
|
{RestServerMetricsType.Status, Response}) do (
|
||||||
state_id: StateIdent, contentBody: Option[ContentBody]) -> RestApiResponse:
|
state_id: StateIdent, contentBody: Option[ContentBody]) -> RestApiResponse:
|
||||||
let
|
let
|
||||||
validatorIds =
|
validatorIds =
|
||||||
|
@ -548,8 +558,9 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
getBalances(node, bslot, validatorIds)
|
getBalances(node, bslot, validatorIds)
|
||||||
|
|
||||||
# https://ethereum.github.io/beacon-APIs/#/Beacon/getEpochCommittees
|
# https://ethereum.github.io/beacon-APIs/#/Beacon/getEpochCommittees
|
||||||
router.api2(MethodGet,
|
router.metricsApi2(
|
||||||
"/eth/v1/beacon/states/{state_id}/committees") do (
|
MethodGet, "/eth/v1/beacon/states/{state_id}/committees",
|
||||||
|
{RestServerMetricsType.Status, Response}) do (
|
||||||
state_id: StateIdent, epoch: Option[Epoch], index: Option[CommitteeIndex],
|
state_id: StateIdent, epoch: Option[Epoch], index: Option[CommitteeIndex],
|
||||||
slot: Option[Slot]) -> RestApiResponse:
|
slot: Option[Slot]) -> RestApiResponse:
|
||||||
let
|
let
|
||||||
|
@ -667,8 +678,9 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
RestApiResponse.jsonError(Http404, StateNotFoundError)
|
RestApiResponse.jsonError(Http404, StateNotFoundError)
|
||||||
|
|
||||||
# https://ethereum.github.io/beacon-APIs/#/Beacon/getEpochSyncCommittees
|
# https://ethereum.github.io/beacon-APIs/#/Beacon/getEpochSyncCommittees
|
||||||
router.api2(MethodGet,
|
router.metricsApi2(
|
||||||
"/eth/v1/beacon/states/{state_id}/sync_committees") do (
|
MethodGet, "/eth/v1/beacon/states/{state_id}/sync_committees",
|
||||||
|
{RestServerMetricsType.Status, Response}) do (
|
||||||
state_id: StateIdent, epoch: Option[Epoch]) -> RestApiResponse:
|
state_id: StateIdent, epoch: Option[Epoch]) -> RestApiResponse:
|
||||||
let
|
let
|
||||||
sid = state_id.valueOr:
|
sid = state_id.valueOr:
|
||||||
|
@ -750,8 +762,9 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
|
|
||||||
# https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/getStateRandao
|
# https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/getStateRandao
|
||||||
# https://github.com/ethereum/beacon-APIs/blob/b3c4defa238aaa74bf22aa602aa1b24b68a4c78e/apis/beacon/states/randao.yaml
|
# https://github.com/ethereum/beacon-APIs/blob/b3c4defa238aaa74bf22aa602aa1b24b68a4c78e/apis/beacon/states/randao.yaml
|
||||||
router.api2(MethodGet,
|
router.metricsApi2(
|
||||||
"/eth/v1/beacon/states/{state_id}/randao") do (
|
MethodGet, "/eth/v1/beacon/states/{state_id}/randao",
|
||||||
|
{RestServerMetricsType.Status, Response}) do (
|
||||||
state_id: StateIdent, epoch: Option[Epoch]) -> RestApiResponse:
|
state_id: StateIdent, epoch: Option[Epoch]) -> RestApiResponse:
|
||||||
let
|
let
|
||||||
sid = state_id.valueOr:
|
sid = state_id.valueOr:
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import std/sequtils
|
import std/sequtils
|
||||||
import chronicles
|
import chronicles, metrics
|
||||||
import ".."/beacon_node,
|
import ".."/beacon_node,
|
||||||
".."/spec/forks,
|
".."/spec/forks,
|
||||||
"."/[rest_utils, state_ttl_cache]
|
"."/[rest_utils, state_ttl_cache]
|
||||||
|
@ -21,15 +21,15 @@ logScope: topics = "rest_debug"
|
||||||
|
|
||||||
proc installDebugApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
proc installDebugApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
# https://ethereum.github.io/beacon-APIs/#/Debug/getState
|
# https://ethereum.github.io/beacon-APIs/#/Debug/getState
|
||||||
router.api2(MethodGet,
|
router.api2(MethodGet, "/eth/v1/debug/beacon/states/{state_id}") do (
|
||||||
"/eth/v1/debug/beacon/states/{state_id}") do (
|
|
||||||
state_id: StateIdent) -> RestApiResponse:
|
state_id: StateIdent) -> RestApiResponse:
|
||||||
RestApiResponse.jsonError(
|
RestApiResponse.jsonError(
|
||||||
Http410, DeprecatedRemovalBeaconBlocksDebugStateV1)
|
Http410, DeprecatedRemovalBeaconBlocksDebugStateV1)
|
||||||
|
|
||||||
# https://ethereum.github.io/beacon-APIs/#/Debug/getStateV2
|
# https://ethereum.github.io/beacon-APIs/#/Debug/getStateV2
|
||||||
router.api2(MethodGet,
|
router.metricsApi2(
|
||||||
"/eth/v2/debug/beacon/states/{state_id}") do (
|
MethodGet, "/eth/v2/debug/beacon/states/{state_id}",
|
||||||
|
{RestServerMetricsType.Status, Response}) do (
|
||||||
state_id: StateIdent) -> RestApiResponse:
|
state_id: StateIdent) -> RestApiResponse:
|
||||||
let bslot =
|
let bslot =
|
||||||
block:
|
block:
|
||||||
|
|
Loading…
Reference in New Issue