Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Health Endpoint #1

Open
27 tasks
jevonearth opened this issue Jun 3, 2024 · 0 comments
Open
27 tasks

Implement Health Endpoint #1

jevonearth opened this issue Jun 3, 2024 · 0 comments
Assignees

Comments

@jevonearth
Copy link
Contributor

jevonearth commented Jun 3, 2024

Implement Health Endpoint

Description

Implement the /health endpoint to monitor the health status of the Tezos RPC node. The endpoint should return a 200 OK status if all the following heuristics pass, and a 500 status if any of them fail:

  1. The bootstrapped property from the /chains/<chain_id>/is_bootstrapped endpoint must be true.
  2. The synced property from the /chains/<chain_id>/is_bootstrapped endpoint must be synced.
  3. The sidecar must observe a new block emitted from the /monitor/heads/<chain_id> endpoint within N + minimal_block_delay seconds.

Tasks

  • Create a /health endpoint
    • Define the endpoint route
    • Implement the logic to return 200 OK or 500 status based on heuristics
  • Monitor the /chains/<chain_id>/is_bootstrapped endpoint
    • Fetch the bootstrapped property
    • Fetch the synced property
  • Observe new blocks from /monitor/heads/<chain_id> within the configured time window
    • Fetch and check new block emission
  • Fetch the minimal_block_delay from the /chains/<chain_id>/blocks/head/context/constants endpoint when a new chain is detected
    • Store and update the minimal_block_delay constant
  • Monitor for changes in the protocol and update the minimal_block_delay constant from the constants RPC when the protocol changes
  • Make the additional-time-window value configurable via a command line flag (default to 10 seconds)
    • Implement command line flag parsing
    • Apply the configurable time window in block observation
  • Log errors when they occur
    • Define error logging format
    • Implement error logging
  • Optionally log HTTP requests to the /health endpoint (enabled by default)
    • Implement request logging
    • Make logging configurable
  • Log all underlying heuristic checks that fail when the health check returns negative
    • Implement detailed logging for failed heuristic checks
  • Create unit and integration tests
    • Write tests for each heuristic
    • Write tests for error handling
  • Update documentation
    • Update README to reflect the new /health endpoint functionality

Acceptance Criteria

  • The /health endpoint returns 200 OK when all heuristics pass.
  • The /health endpoint returns 500 when any heuristic fails.
  • Errors are logged as specified.
  • HTTP requests to the /health endpoint are logged by default.
  • Failed heuristic checks are logged in detail when the health check returns negative.
  • Tests are implemented and passing.
  • Documentation is updated to reflect the new feature.

Notes

  • The sidecar should fetch the active chain ID once from the /monitor/active_chains endpoint and assume it does not change.
  • Ensure that the health checks are efficient and do not overload the Tezos RPC node.
  • Implement logging for error conditions and optionally for all HTTP requests to the /health endpoint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants