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

Increase logs #657

Merged
merged 4 commits into from
Feb 28, 2025
Merged

Increase logs #657

merged 4 commits into from
Feb 28, 2025

Conversation

jeandemeusy
Copy link
Collaborator

@jeandemeusy jeandemeusy commented Feb 28, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a GraphQLProvider class for managing GraphQL queries with enhanced error handling and metrics tracking.
  • Refactor

    • Standardized the way data is processed and responses are managed.
    • Improved internal logging by incorporating additional contextual information for clearer diagnostics.
    • Adopted consistent naming conventions for improved readability.
  • Chores

    • Updated configuration settings to enable more detailed debug logging for specific components.
    • Incremented version tag for the core component in deployment configuration.

Copy link
Contributor

coderabbitai bot commented Feb 28, 2025

📝 Walkthrough

Walkthrough

This pull request refactors several modules and adjusts logging and import organization. In the API layer, the HoprdAPI now accesses all request and response objects through dedicated namespaces with updated type annotations and logging calls. Minor formatting improvements and newline additions were applied to request object files. The core modules update import paths and add logging details, while the Node class now provides a property for contextual log parameters. The subgraph package is reorganized by introducing a new GraphQLProvider class, renaming a method in Mode, and removing obsolete provider definitions. A test function and an environment variable have also been updated.

Changes

File(s) Change Summary
ct-app/core/api/hoprd_api.py Refactored request/response imports; updated method signatures and return types; switched error logging from logger.exception to logger.error.
ct-app/core/api/request_objects.py Inserted additional newlines after __init__ methods for improved readability; no functional changes.
ct-app/core/core.py Updated import path for GraphQLProvider; added an info-level log in rotate_subgraphs and adjusted log formatting in registered_nodes.
ct-app/core/node.py Added a new log_base_params property for contextual logging; enhanced log statements for node reachability and message handling.
ct-app/core/subgraph/init.py, mode.py, providers.py, graphql_provider.py Updated the __all__ exports and import sources; introduced a new GraphQLProvider in graphql_provider.py; renamed toInt to to_int in Mode; removed old GraphQLProvider and ProviderError definitions from providers.py.
ct-app/test/model/test_subgraph_type.py Renamed test function from test_toInt to test_to_int to adhere to snake_case naming.
helm/values-prod-blue.yaml Modified the RUST_LOG environment variable to include hopr_transport_p2p=debug alongside info.
helm/values-prod.yaml Updated the tag from v3.9.1 to v3.9.2 in ctdapp.core.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant GP as GraphQLProvider
    participant HTTP as aiohttp

    C->>GP: get(queryKey)
    GP->>GP: _initialize_query(queryKey)
    GP->>GP: _load_query(query_file)
    GP->>HTTP: _execute(query)
    HTTP-->>GP: Response or Error
    GP->>C: Return data or error
Loading

Possibly related PRs

  • Uniquely identify each sent and received message #625: The changes in the main PR are related to those in the retrieved PR as both involve modifications to the send_message method in the HoprdAPI class, specifically regarding its return type and handling of response objects.
  • Generate logs in json format #652: The changes in the main PR, which involve refactoring the HoprdAPI class's logging and error handling mechanisms, are related to the modifications in the retrieved PR that also focus on enhancing logging functionality across various components, including the HoprdAPI class.
  • Fix message count calculation #615: The changes in the main PR, which involve refactoring method signatures and import structures in the HoprdAPI class, are related to the modifications in the retrieved PR that also affect the HoprdAPI class, specifically the ticket_price method's internal logic and the removal of the winning_probability method.

Suggested labels

status:in-progress

Suggested reviewers

  • Teebor-Choka

📜 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 8776139 and cab0a77.

📒 Files selected for processing (1)
  • helm/values-prod.yaml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • helm/values-prod.yaml
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and push container image

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 generate docstrings to generate docstrings for 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: 2

🧹 Nitpick comments (4)
ct-app/core/node.py (2)

61-65: Great addition of a structured log parameters property.

The new log_base_params property creates a consistent dictionary of contextual information (URL, address, peer_id) that's used across all log messages, which improves log analysis and correlation.

Consider adding null checks for self.address to avoid potential AttributeError if self.address is None - though the current implementation with getattr handles this well.


69-74: Improved log message for safe address retrieval.

The logging now includes the node's contextual information through log_base_params, making it easier to correlate logs.

Consider combining the nested if statements as suggested by static analysis:

-        if self._safe_address is None:
-            if info := await self.api.node_info():
+        if self._safe_address is None and (info := await self.api.node_info()):
🧰 Tools
🪛 Ruff (0.8.2)

69-70: Use a single if statement instead of nested if statements

Combine if statements using and

(SIM102)

ct-app/core/subgraph/graphql_provider.py (1)

65-83: Consider reusing the session and handling non-2xx status codes.

  1. Initializing a fresh ClientSession for each request adds overhead. Reusing the session for multiple queries often improves performance.
  2. The current implementation does not explicitly handle non-2xx HTTP status codes beyond exceptions. Logging or raising an error for unsuccessful status codes may help with debugging.
ct-app/core/api/hoprd_api.py (1)

55-60: Consider using logger.exception for richer tracebacks.

Replacing logger.exception with logger.error removes the stack trace. If you need detailed debugging info for OSError or unknown exceptions, reverting to logger.exception might be helpful.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 56a989c and 8776139.

📒 Files selected for processing (10)
  • ct-app/core/api/hoprd_api.py (9 hunks)
  • ct-app/core/api/request_objects.py (2 hunks)
  • ct-app/core/core.py (3 hunks)
  • ct-app/core/node.py (17 hunks)
  • ct-app/core/subgraph/__init__.py (1 hunks)
  • ct-app/core/subgraph/graphql_provider.py (1 hunks)
  • ct-app/core/subgraph/mode.py (1 hunks)
  • ct-app/core/subgraph/providers.py (2 hunks)
  • ct-app/test/model/test_subgraph_type.py (1 hunks)
  • helm/values-prod-blue.yaml (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • ct-app/core/api/request_objects.py
  • ct-app/test/model/test_subgraph_type.py
  • ct-app/core/subgraph/mode.py
🧰 Additional context used
🪛 Ruff (0.8.2)
ct-app/core/node.py

69-70: Use a single if statement instead of nested if statements

Combine if statements using and

(SIM102)

ct-app/core/subgraph/graphql_provider.py

50-50: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and push container image
🔇 Additional comments (30)
helm/values-prod-blue.yaml (1)

13-13: Increased logging for p2p transport module.

This change enhances the logging configuration by enabling debug-level logs specifically for the hopr_transport_p2p component while maintaining info-level for other components.

Since this is a production environment, please confirm this increased verbosity is intentional and acceptable from a performance perspective, as debug logs can increase log volume significantly.

ct-app/core/subgraph/__init__.py (2)

2-2: Updated import source for ProviderError.

The import for ProviderError has been moved from providers to graphql_provider, reflecting the reorganization of the codebase. The GraphQLProvider class is now also imported from the same module.


7-14: Reorganized exported entities in __all__.

The __all__ list has been updated to include GraphQLProvider and reintroduce Mode and URL, which improves clarity about which elements are part of the public API.

ct-app/core/core.py (3)

8-8: Updated import path for GraphQLProvider.

The import for GraphQLProvider has been changed from core.subgraph.providers to core.subgraph, reflecting the reorganization of the codebase structure.


88-88: Added informative log message for subgraph rotation.

A new log message has been added at the info level to indicate when subgraphs are being rotated, improving observability of this operation.


164-164: Improved log formatting with consistent spacing.

Added proper spacing between the log message and the dictionary parameters for better readability.

ct-app/core/node.py (21)

84-85: Enhanced log message with contextual information.

Updated log message to include the node's base parameters, improving observability.


89-90: Improved debug log with context parameters.

The log message now includes node context via log_base_params and has proper whitespace formatting.


103-103: Added context to warning log about node reachability.

Enhanced warning message with node identification details from log_base_params.


105-105: Enhanced address retrieval failure log.

Added contextual information to the warning about missing address.


119-121: Improved balance retrieval logging.

Added node context to the warning message about balance retrieval failure.


124-125: Enhanced balance retrieval success log.

The log now includes both balance information and node context parameters.


152-153: Improved log for channel opening process.

Added node context to channel opening log, making it easier to track which node is performing channel operations.


169-170: Added context to incoming channel closure log.

Improved log message with node identification information.


187-188: Enhanced pending channel closure log.

Added node context to the log message about pending channel closure.


228-229: Improved old channel closure log message.

Added context parameters to the log for dangling channel closure.


251-253: Enhanced channel funding log message.

Improved the log with additional context about the node performing the operation.


268-269: Minor formatting improvement in peer creation.

Reformatted the set comprehension for better readability.


278-279: Added context to peer scanning log.

Enhanced the log message about reachable peers with node identification information.


314-315: Improved channel scanning log message.

Added node context to the channel scanning log for better observability.


330-330: Extracted channel funds value with more explicit nested access.

Improved the code to use dict.get() with nested access pattern for better robustness.


332-333: Enhanced logging for channel funds retrieval.

Added node context to the log message about funds in outgoing channels.


343-349: Added important warning for potential inbox overflow.

Added a new warning when the message count is a power of 2, which could indicate a full inbox. This is a good defensive check.

Could you confirm that checking for powers of 2 (count && !(count & (count - 1))) is the correct way to detect a full inbox? This seems like it would trigger for counts of 1, 2, 4, 8, 16, etc. - is this expected?


354-355: Improved error logging for message parsing.

Enhanced the exception log with node context for better troubleshooting.


361-364: Improved metrics labeling with consistent formatting.

Reformatted the metrics labels for better readability and consistency.


368-368: Minor code style improvement.

Simplified the code by using await MessageQueue().get_async() directly.


385-388: Improved message sending code formatting.

Enhanced readability of the message sending code with consistent indentation and spacing.

ct-app/core/subgraph/providers.py (2)

1-1: Looks good!

Importing the GraphQLProvider from the new module is straightforward and aligns with the refactored structure.


28-28: Verify that the GraphQL type matches.

'$id_in: [Bytes!] = [""]' suggests a custom scalar or specific schema requirement. Please ensure the subgraph schema includes a Bytes! type for this parameter.

ct-app/core/api/hoprd_api.py (1)

10-11: Consolidated import structure looks clean.

Switching to namespaced imports (request, response) improves maintainability and readability.

@jeandemeusy jeandemeusy self-assigned this Feb 28, 2025
@jeandemeusy jeandemeusy merged commit 9d34c65 into main Feb 28, 2025
3 checks passed
@jeandemeusy jeandemeusy deleted the prod/debug-logs branch February 28, 2025 14:10
@coderabbitai coderabbitai bot mentioned this pull request Feb 28, 2025
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.

1 participant