Skip to content

Conversation

@DZakh
Copy link
Member

@DZakh DZakh commented May 22, 2025

Summary by CodeRabbit

  • New Features
    • Added tracking of time spent in different operational states (idle, waiting for new blocks, querying) for improved monitoring.
    • Introduced new Prometheus metrics to monitor idle time, source waiting time, and query time in milliseconds.
    • Enhanced Prometheus metrics to update source height when new block heights are detected.
    • Added support for the Swell network and updated Moonbeam network classification in network categorization and threshold logic.
    • Extended metric increment functionality to support incrementing by arbitrary integer values.

@DZakh DZakh requested a review from JonoPrest May 22, 2025 14:38
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 22, 2025

Walkthrough

The changes introduce enhanced Prometheus metric tracking for source manager states and source height, add new Prometheus counter modules, and extend the Prometheus metric interface. Additionally, the Network enum is updated to include a new Swell variant and adjust the classification of Moonbeam, with corresponding updates to network tiering and block confirmation logic.

Changes

File(s) Change Summary
codegenerator/cli/npm/envio/src/Prometheus.res Added incrementMany to the MakeSafePromMetric interface. Introduced modules IndexingIdleTime, IndexingSourceWaitingTime, and IndexingQueryTime with new Prometheus counters for tracking source manager status durations.
codegenerator/cli/npm/envio/src/sources/SourceManager.res Added status tracking to the source manager with a new status enum, timer, and the trackNewStatus function. Integrated Prometheus metric updates for time spent in each state during block fetching and querying.
codegenerator/cli/src/config_parsing/chain_helpers.rs Added Swell as a new Network enum variant and included it in the HypersyncNetwork subenum. Updated Moonbeam to also be a HypersyncNetwork. Adjusted network tiering and block confirmation threshold logic for these variants.
codegenerator/cli/templates/static/codegen/src/globalState/GlobalState.res Updated validatePartitionQueryResponse to set Prometheus SourceHeight metric when a new highest block is detected, using chain ID and source name as labels.

Sequence Diagram(s)

sequenceDiagram
    participant SourceManager
    participant Prometheus

    SourceManager->>Prometheus: trackNewStatus(Idle/WaitingForNewBlock/Querieng)
    Note right of SourceManager: On status change, record elapsed time to Prometheus counters

    SourceManager->>Prometheus: incrementMany(counter, labels, value)
    Note right of Prometheus: Counter for time spent in each state is updated

    GlobalState->>Prometheus: set(SourceHeight, {chainId, source}, blockNumber)
    Note right of Prometheus: Updates metric if new highest block is detected
Loading

Suggested reviewers

  • JasoonS

Poem

In burrows deep, the metrics grow,
With counters counting status flow.
A new Swell rises in the chain,
Moonbeam joins the Hypersync train.
Rabbits hop and numbers climb,
Prometheus tracks it all in time!
🐇📊✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bed114f and 82a3958.

📒 Files selected for processing (1)
  • codegenerator/cli/templates/static/codegen/src/globalState/GlobalState.res (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • codegenerator/cli/templates/static/codegen/src/globalState/GlobalState.res
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build_and_test

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
codegenerator/cli/npm/envio/src/sources/SourceManager.res (1)

3-4: Typo in enum variant "Querieng".

There appears to be a spelling error in the sourceManagerStatus enum variant - "Querieng" should likely be "Querying".

-type sourceManagerStatus = Idle | WaitingForNewBlock | Querieng
+type sourceManagerStatus = Idle | WaitingForNewBlock | Querying

Ensure this change is also applied to all references of this variant throughout the code.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 540f85a and bed114f.

📒 Files selected for processing (4)
  • codegenerator/cli/npm/envio/src/Prometheus.res (3 hunks)
  • codegenerator/cli/npm/envio/src/sources/SourceManager.res (5 hunks)
  • codegenerator/cli/src/config_parsing/chain_helpers.rs (4 hunks)
  • codegenerator/cli/templates/static/codegen/src/globalState/GlobalState.res (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
codegenerator/cli/src/config_parsing/chain_helpers.rs (1)
codegenerator/cli/src/cli_args/interactive_init/evm_prompts.rs (1)
  • HypersyncNetwork (224-232)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build_and_test
🔇 Additional comments (11)
codegenerator/cli/templates/static/codegen/src/globalState/GlobalState.res (1)

346-355: Great addition of source height metrics to Prometheus.

This change enhances observability by tracking the current block height from data sources in Prometheus metrics. The metric is properly labeled with chain ID and source name for easy correlation.

codegenerator/cli/npm/envio/src/Prometheus.res (2)

126-131: Nice addition of incrementMany method for metrics.

The new method appropriately extends the metric interface to support incrementing counters by arbitrary values, not just by one. This is essential for tracking elapsed time measurements.


367-389: Good addition of indexing performance metrics.

These new counter modules will provide valuable insights into where time is spent during indexing:

  • IndexingIdleTime: tracks idle time (potential bottleneck indicator)
  • IndexingSourceWaitingTime: tracks time waiting for new blocks
  • IndexingQueryTime: tracks time spent querying chain data-sources

The metrics use consistent naming conventions and include helpful descriptions.

codegenerator/cli/src/config_parsing/chain_helpers.rs (4)

253-253: Correctly updated Moonbeam network configuration.

Adding the HypersyncNetwork subenum to Moonbeam ensures it's properly categorized for hypersync-related functionality.


343-344: Good addition of Swell network.

The new Swell network has been properly added with a unique ID (1923) and correctly tagged with the HypersyncNetwork subenum.


528-529: Properly updated block confirmation threshold.

The Swell network has been added to the appropriate match arm to use the default confirmed block threshold, consistent with similar networks like Sonic.


589-589: Correctly updated network tier classification.

Both Swell and Moonbeam have been properly added to the Stone tier in the HypersyncNetwork's get_tier method.

codegenerator/cli/npm/envio/src/sources/SourceManager.res (4)

12-13: Good addition of status tracking fields.

These new fields provide the foundation for tracking the operational state of the source manager and measuring time spent in each state.


73-75: Proper initialization of new fields.

The status is correctly initialized to Idle with a new timer at creation time.


78-90: Well-implemented status tracking function.

The trackNewStatus function properly:

  1. Selects the appropriate Prometheus counter based on the new status
  2. Records the elapsed time in the previous status
  3. Resets the timer for the new status
  4. Updates the status field

119-120: Good placement of status tracking calls.

Status transitions are tracked at key points in the fetchNext function:

  • When entering WaitingForNewBlock state
  • When returning to Idle after waiting for a new block
  • When starting query execution
  • When all queries complete

This provides comprehensive coverage of the source manager's lifecycle.

Also applies to: 124-125, 140-141, 151-153

@DZakh DZakh enabled auto-merge (squash) May 22, 2025 15:04
@DZakh DZakh merged commit 818c7ca into main May 22, 2025
2 checks passed
@DZakh DZakh deleted the dz/indexing-performance-metrics branch May 22, 2025 15:12
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

Successfully merging this pull request may close these issues.

3 participants