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

fix(torii): improve log messages #2463

Merged
merged 1 commit into from
Sep 24, 2024
Merged

fix(torii): improve log messages #2463

merged 1 commit into from
Sep 24, 2024

Conversation

lambda-0x
Copy link
Collaborator

@lambda-0x lambda-0x commented Sep 22, 2024

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced logging for data fetching operations to include timing measurements, providing better performance insights.
  • Chores

    • Adjusted logging levels from info to debug in several components to reduce verbosity and focus on essential logs.

Copy link

coderabbitai bot commented Sep 22, 2024

Walkthrough

Ohayo, sensei! The changes in this pull request focus on enhancing logging functionality across several files in the torii crate. Key modifications include the introduction of timing measurements in engine.rs for data fetching operations and adjustments to the logging levels from info to debug in various processor files. These adjustments aim to provide more detailed insights into operations while reducing the prominence of certain log messages.

Changes

File Path Change Summary
crates/torii/core/src/engine.rs Introduced timing measurements for data fetching operations using Instant from tokio::time.
crates/torii/core/src/processors/store_del_record.rs Changed logging level from info to debug for delete record storage messages.
crates/torii/core/src/processors/store_set_record.rs Changed logging level from info to debug for storing set record messages.
crates/torii/core/src/processors/store_update_member.rs Changed logging level from info to debug for member not found messages.
crates/torii/core/src/processors/store_update_record.rs Changed logging level from info to debug for model name and entity ID logging.

Possibly related PRs

  • refactor: use debug for process pendign logs #2401: The changes in this PR also involve modifications to the logging level in the engine.rs file, specifically changing a log message from info to debug, which aligns with the logging enhancements made in the main PR.

Suggested reviewers

  • glihm: Suggested for their expertise in the relevant areas of the codebase.

Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 880661d and 95ebf64.

Files selected for processing (1)
  • crates/torii/core/src/engine.rs (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • crates/torii/core/src/engine.rs

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.
    -- Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    -- @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 generate unit testing code.
    -- @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.

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 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.

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

@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

Outside diff range and nitpick comments (3)
crates/torii/core/src/engine.rs (3)

215-226: Ohayo, sensei! Consider adjusting log levels for timing info.

The addition of timing measurements is excellent for performance monitoring. However, logging these durations at the info level might be too verbose, especially if this operation occurs frequently.

Consider changing these new timing logs to the debug level:

-            info!(target: LOG_TARGET, duration = ?instant.elapsed(), from = %from, to = %latest_block_number, "Fetched data for range.");
+            debug!(target: LOG_TARGET, duration = ?instant.elapsed(), from = %from, to = %latest_block_number, "Fetched data for range.");

-            info!(target: LOG_TARGET, duration = ?instant.elapsed(), latest_block_number = %latest_block_number, "Fetched pending data.");
+            debug!(target: LOG_TARGET, duration = ?instant.elapsed(), latest_block_number = %latest_block_number, "Fetched pending data.");

This change will reduce log verbosity while still allowing detailed timing information when needed.


Line range hint 174-192: Ohayo again, sensei! Let's fine-tune the logging for processing too.

The addition of timing measurements for data processing is a great improvement. However, similar to the fetching logs, this timing information might be too verbose at the info level.

Consider changing this new timing log to the debug level:

-            info!(target: LOG_TARGET, duration = ?instant.elapsed(), "Processed fetched data.");
+            debug!(target: LOG_TARGET, duration = ?instant.elapsed(), "Processed fetched data.");

This adjustment will maintain consistency with the previous suggestion and help manage log verbosity.


Line range hint 1-738: Ohayo once more, sensei! Overall, these changes are sugoi!

The introduction of timing measurements for key operations is a valuable addition to the codebase. It enhances observability without impacting core functionality, which is excellent.

For future enhancements, consider implementing a more structured approach to performance monitoring:

  1. Create a dedicated performance monitoring module that can be easily enabled/disabled.
  2. Use a configuration flag to control the verbosity of timing logs.
  3. Consider integrating with a metrics collection system (e.g., Prometheus) for more comprehensive performance tracking.

These suggestions could further improve the system's observability and make performance tuning easier in the long run.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 86dbd44 and 880661d.

Files selected for processing (5)
  • crates/torii/core/src/engine.rs (4 hunks)
  • crates/torii/core/src/processors/store_del_record.rs (2 hunks)
  • crates/torii/core/src/processors/store_set_record.rs (2 hunks)
  • crates/torii/core/src/processors/store_update_member.rs (2 hunks)
  • crates/torii/core/src/processors/store_update_record.rs (2 hunks)
Additional comments not posted (6)
crates/torii/core/src/processors/store_del_record.rs (2)

Line range hint 52-56: Ohayo, sensei! LGTM: Improved log level for better verbosity control.

The change from info to debug log level is a good improvement. It reduces log verbosity during normal operation while still providing useful information for debugging purposes. This aligns well with the PR objective to enhance log messages.


Line range hint 1-65: Ohayo again, sensei! Overall impact: Positive and low-risk change.

The modification to the log level is an isolated change that doesn't affect the core functionality of the StoreDelRecordProcessor. It improves the logging strategy by reducing unnecessary verbosity during normal operation. This change is low-risk and aligns well with the PR's objective to enhance log messages.

crates/torii/core/src/processors/store_set_record.rs (1)

Line range hint 53-57: Ohayo, sensei! LGTM: Logging level adjustment approved.

The change from info! to debug! for the "Store set record" log message is a good improvement. This adjustment reduces log verbosity in production environments while still maintaining the ability to access detailed information when needed during debugging.

This modification aligns well with the PR objective to enhance log messages and adjust logging levels. It doesn't affect the functionality of the code, only its logging behavior.

crates/torii/core/src/processors/store_update_record.rs (1)

Line range hint 55-59: Ohayo, sensei! Nice log level adjustment!

The change from info! to debug! macro is a good improvement. It reduces log verbosity in production while still allowing detailed logging when needed during debugging sessions.

This change aligns well with the PR objective of improving log messages. It maintains the valuable information about store update records without cluttering the default log output.

crates/torii/core/src/processors/store_update_member.rs (1)

Line range hint 73-79: Ohayo, sensei! LGTM on the logging level change.

The modification from info! to debug! for the "Store update member" log is a good improvement. It reduces log verbosity while still maintaining valuable debugging information.

To ensure consistency, let's verify if similar logging statements in related files have been updated:

Verification successful

All 'info!' Logs Successfully Updated

Ohayo, sensei! I’ve verified that there are no remaining info! logs related to store updates in the codebase. The logging level change from info! to debug! has been successfully implemented.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining 'info!' logs related to store updates
rg --type rust 'info!.*"Store update' crates/torii

Length of output: 52

crates/torii/core/src/engine.rs (1)

21-21: Ohayo, sensei! Nice import consolidation!

The change consolidates the sleep import and adds Instant for time measurements. This is a good practice for keeping imports organized and introducing necessary timing functionality.

Copy link

codecov bot commented Sep 22, 2024

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 68.47%. Comparing base (b598b07) to head (95ebf64).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
crates/torii/core/src/engine.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2463      +/-   ##
==========================================
+ Coverage   68.45%   68.47%   +0.01%     
==========================================
  Files         368      368              
  Lines       48162    48164       +2     
==========================================
+ Hits        32971    32979       +8     
+ Misses      15191    15185       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@glihm glihm left a comment

Choose a reason for hiding this comment

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

@lambda-0x shouldn't be more debug or even trace log level for those?

crates/torii/core/src/engine.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@glihm glihm left a comment

Choose a reason for hiding this comment

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

Let's keep info for everything that changes torii state and pass to debug for the actual fetching/processing details.

@glihm glihm merged commit 78250fa into main Sep 24, 2024
14 of 15 checks passed
@glihm glihm deleted the spr/main/88796bb8 branch September 24, 2024 20:27
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.

2 participants