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

chore: facilitate trace certificates filtering #142

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jeluard
Copy link
Contributor

@jeluard jeluard commented Mar 12, 2025

Introduce a new trace target amaru::ledger::state::transaction::certificates so that certificate handling can be traced easily.

e.g. AMARU_LOG="amaru::ledger::state::transaction::certificate=trace"

Summary by CodeRabbit

  • Refactor

    • Enhanced logging output for certificate operations with more precise and concise descriptions, improving overall clarity.
  • Documentation

    • Updated logging configuration details with revised environment variable settings and default log level behaviour, making event filtering and trace naming more straightforward.

Copy link

coderabbitai bot commented Mar 12, 2025

Walkthrough

This pull request refines the logging mechanism for certificate-related actions and updates the monitoring documentation. In the ledger module, a new constant CERTIFICATES_EVENT_TARGET is introduced to provide a focused event target for certificate logs, and logging statements in the apply_certificate function are updated to utilise it while simplifying the log messages. The monitoring README now replaces AMARU_DEV_LOG with AMARU_TRACE, clarifies the purpose of AMARU_LOG, adjusts default log levels, and streamlines trace names.

Changes

File(s) Change Summary
crates/amaru-ledger/src/.../transaction.rs Added constant CERTIFICATES_EVENT_TARGET; updated logging in apply_certificate to use the new constant and removed the "certificate." prefix for more concise logs.
monitoring/README.md Replaced AMARU_DEV_LOG with AMARU_TRACE; updated AMARU_LOG description and default logging behaviour; simplified trace names and added an example usage.

Suggested reviewers

  • KtorZ

Poem

In lines of code and logs so neat,
Certificates now find their beat.
A tweak here, a change so sly,
Like tea at teatime, oh my!
Cheers to updates that just click! 😊

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

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

Base automatically changed from jeluard/dreps to main March 12, 2025 19:17
@jeluard jeluard force-pushed the jeluard/better-certificate-traces branch from 7260416 to 91cc773 Compare March 13, 2025 06:14
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 comments (2)
monitoring/README.md (2)

225-239: 🛠️ Refactor suggestion

Fix trace summary section headings

The headings for two trace sections appear to be incorrect. They should match the actual trace names being used in the code.

- <details><summary>trace: `stake.registration`</summary>
+ <details><summary>trace: `pool.registration`</summary>

...

- <details><summary>trace: `stake.retirement`</summary>
+ <details><summary>trace: `pool.retirement`</summary>

These sections are describing pool operations based on the field descriptions, but the headings incorrectly label them as stake operations.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

230-230: Tables should be surrounded by blank lines
null

(MD058, blanks-around-tables)


238-238: Tables should be surrounded by blank lines
null

(MD058, blanks-around-tables)


241-265: 🛠️ Refactor suggestion

Update remaining detail section headings

The remaining detail section headings still contain the "certificate." prefix which should be removed to maintain consistency with the updated trace names.

- <details><summary>trace: `certificate.drep.registration`</summary>
+ <details><summary>trace: `drep.registration`</summary>

...

- <details><summary>trace: `certificate.drep.retirement`</summary>
+ <details><summary>trace: `drep.retirement`</summary>

...

- <details><summary>trace: `certificate.vote.delegation`</summary>
+ <details><summary>trace: `vote.delegation`</summary>
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

246-246: Tables should be surrounded by blank lines
null

(MD058, blanks-around-tables)


255-255: Tables should be surrounded by blank lines
null

(MD058, blanks-around-tables)


264-264: Tables should be surrounded by blank lines
null

(MD058, blanks-around-tables)

🧹 Nitpick comments (1)
monitoring/README.md (1)

18-18: Fix grammatical error in environment variables description

There's a small grammatical number issue in the tip text.

- > Both environment variable are optional.
+ > Both environment variables are optional.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~18-~18: The grammatical number of this noun doesn’t look right. Consider replacing it.
Context: ...to stdout; > [!TIP] > Both environment variable are optional. > > - When omitted, `AMAR...

(AI_EN_LECTOR_REPLACEMENT_NOUN_NUMBER)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c32e7da and 91cc773.

📒 Files selected for processing (2)
  • crates/amaru-ledger/src/state/transaction.rs (3 hunks)
  • monitoring/README.md (3 hunks)
🧰 Additional context used
🪛 LanguageTool
monitoring/README.md

[uncategorized] ~14-~14: Loose punctuation mark.
Context: ... environment variables: - AMARU_TRACE: for any event emitted by the OpenTeleme...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~18-~18: The grammatical number of this noun doesn’t look right. Consider replacing it.
Context: ...to stdout; > [!TIP] > Both environment variable are optional. > > - When omitted, `AMAR...

(AI_EN_LECTOR_REPLACEMENT_NOUN_NUMBER)

🪛 markdownlint-cli2 (0.17.2)
monitoring/README.md

207-207: Tables should be surrounded by blank lines
null

(MD058, blanks-around-tables)


215-215: Tables should be surrounded by blank lines
null

(MD058, blanks-around-tables)


222-222: Tables should be surrounded by blank lines
null

(MD058, blanks-around-tables)


230-230: Tables should be surrounded by blank lines
null

(MD058, blanks-around-tables)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Snapshots (preprod, 10.1.4)
  • GitHub Check: Build on windows-latest with target x86_64-pc-windows-msvc
🔇 Additional comments (6)
crates/amaru-ledger/src/state/transaction.rs (2)

33-33: Nice addition of dedicated event target for certificates!

The new CERTIFICATES_EVENT_TARGET constant provides a more focused way to trace certificate operations. This is a cracker of an improvement for devs who need to filter logs specifically for certificate handling.


241-241: LGTM! Consistent update of trace targets

You've done a brilliant job updating all the trace statements to use the new certificate-specific target. The simplified log messages (removing the redundant "certificate." prefix) make the logs cleaner and easier to scan.

Also applies to: 245-245, 249-249, 255-255, 259-259, 263-263, 293-293, 299-299, 303-303, 307-307

monitoring/README.md (4)

14-15: Environment variable names and descriptions updated correctly

Good job renaming AMARU_DEV_LOG to AMARU_TRACE and clarifying the purpose of each variable. This makes the distinction between OpenTelemetry layer events and stdout events crystal clear.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~14-~14: Loose punctuation mark.
Context: ... environment variables: - AMARU_TRACE: for any event emitted by the OpenTeleme...

(UNLIKELY_OPENING_PUNCTUATION)


20-21: Default log levels updated appropriately

The updated default log levels provide better granularity - setting AMARU_LOG to "debug" level and AMARU_TRACE to "trace" level makes perfect sense for the different use cases.


36-37: Great example addition!

Adding a practical example of how to filter events by target and severity is spot on. This will be a lifesaver for developers trying to set up their logging configurations.


183-201: Comprehensive documentation of the new trace target

The addition of the new amaru::ledger::state::transaction::certificates target section is well-structured and aligns perfectly with the code changes. The simplified trace names (without the "certificate." prefix) match the updated logging statements in the code.

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