Conversation
Reviewer's GuideReplaced unstructured stderr prints with structured tracing macros in server.rs, mapping each eprintln! to an appropriate tracing level (warn or error) while preserving test behavior. Class diagram for logging changes in server.rsclassDiagram
class Server {
+worker_task()
+process_stream()
}
class Tracing {
+warn()
+error()
}
Server ..> Tracing : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
WalkthroughUpdate the project to use structured logging by adding the Changes
Sequence Diagram(s)sequenceDiagram
participant Main
participant TracingSubscriber
participant Server
participant Logger
Main->>TracingSubscriber: init()
Main->>Server: start()
Server->>Logger: log (via tracing macros)
Logger-->>TracingSubscriber: structured log event
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes - here's some feedback:
- Ensure a tracing subscriber (e.g. using tracing_subscriber::fmt::init()) is initialized early so these new logs actually get emitted.
- Consider attaching contextual fields like peer address or connection ID to the tracing logs for better observability of errors.
- Review log level choices for consistency—e.g., confirm recoverable errors stay as warn! and critical failures remain error! throughout the module.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Ensure a tracing subscriber (e.g. using tracing_subscriber::fmt::init()) is initialized early so these new logs actually get emitted.
- Consider attaching contextual fields like peer address or connection ID to the tracing logs for better observability of errors.
- Review log level choices for consistency—e.g., confirm recoverable errors stay as warn! and critical failures remain error! throughout the module.
## Individual Comments
### Comment 1
<location> `src/server.rs:706` </location>
<code_context>
})
.on_preamble_decode_failure(|_: &DecodeError| {
- eprintln!("Preamble decode failed");
+ tracing::warn!("Preamble decode failed");
})
.bind(free_port)
</code_context>
<issue_to_address>
Include error context in the warning log.
Including error details in the log will make troubleshooting easier. Please add relevant error information to the warning message.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
.on_preamble_decode_failure(|_: &DecodeError| {
tracing::warn!("Preamble decode failed");
})
=======
.on_preamble_decode_failure(|err: &DecodeError| {
tracing::warn!(error = ?err, "Preamble decode failed");
})
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@coderabbitai Have the following now been resolved? |
There was a problem hiding this comment.
Code Health Improved
(1 files improve in Code Health)
Gates Passed
6 Quality Gates Passed
See analysis details in CodeScene
View Improvements
| File | Code Health Impact | Categories Improved |
|---|---|---|
| push.rs | 9.69 → 10.00 | Complex Conditional |
Quality Gate Profile: Pay Down Tech Debt
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 40014 @leynos Yes, all three recommendations have been resolved: ✅ 1. Tracing subscriber initializationThe tracing subscriber is properly initialized in fn main() {
// Enable structured logging for examples and integration tests.
// Applications embedding the library should install their own subscriber.
tracing_subscriber::fmt::init();
println!("Hello from Wireframe!");
}✅ 2. Contextual fields attached to logsThe tracing calls now include relevant contextual information:
✅ 3. Consistent log level choicesThe log levels are appropriately chosen throughout the module:
The implementation demonstrates proper observability practices with structured logging and appropriate contextual information for debugging connection issues. |
There was a problem hiding this comment.
Code Health Improved
(1 files improve in Code Health)
Gates Passed
6 Quality Gates Passed
See analysis details in CodeScene
View Improvements
| File | Code Health Impact | Categories Improved |
|---|---|---|
| push.rs | 9.69 → 10.00 | Complex Conditional |
Quality Gate Profile: Pay Down Tech Debt
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.
There was a problem hiding this comment.
Code Health Improved
(1 files improve in Code Health)
Gates Passed
6 Quality Gates Passed
See analysis details in CodeScene
View Improvements
| File | Code Health Impact | Categories Improved |
|---|---|---|
| push.rs | 9.69 → 10.00 | Complex Conditional |
Quality Gate Profile: Pay Down Tech Debt
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
src/server.rs (1)
743-745: LGTM: Structured logging in test callback.The test properly uses
tracing::warn!with error context, maintaining consistency with the production logging approach.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (5)
Cargo.toml(1 hunks)docs/observability-operability-and-maturity.md(1 hunks)examples/metadata_routing.rs(1 hunks)src/main.rs(1 hunks)src/server.rs(4 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.rs
📄 CodeRabbit Inference Engine (AGENTS.md)
**/*.rs: Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Useconcat!()to combine long string literals rather than escaping newlines with a backslash.
Prefer semantic error enums: Derivestd::error::Error(via thethiserrorcrate) for any condition the caller might inspect, retry, or map to an HTTP status.
Use an opaque error only at the app boundary: Useeyre::Reportfor human-readable logs; these should not be exposed in public APIs.
Never export the opaque type from a library: Convert to domain enums at API boundaries, and toeyreonly in the mainmain()entrypoint or top-level async task.
Files:
examples/metadata_routing.rssrc/main.rssrc/server.rs
⚙️ CodeRabbit Configuration File
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/Files must not exceed 400 lines in length
- Large modules must be decomposed
- Long match statements or dispatch tables should be decomposed by domain and collocated with targets
- Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.
Files:
examples/metadata_routing.rssrc/main.rssrc/server.rs
Cargo.toml
📄 CodeRabbit Inference Engine (AGENTS.md)
Cargo.toml: Use explicit version ranges inCargo.tomland keep dependencies up-to-date.
Mandate caret requirements for all dependencies: All crate versions specified inCargo.tomlmust use SemVer-compatible caret requirements (e.g.,some-crate = "1.2.3").
Prohibit unstable version specifiers: The use of wildcard (*) or open-ended inequality (>=) version requirements is strictly forbidden inCargo.toml.
Tilde requirements (~) should only be used where a dependency must be locked to patch-level updates for a specific, documented reason.
Files:
Cargo.toml
docs/**/*.md
📄 CodeRabbit Inference Engine (AGENTS.md)
docs/**/*.md: Use the markdown files within thedocs/directory as a knowledge base and source of truth for project requirements, dependency choices, and architectural decisions.
When new decisions are made, requirements change, libraries are added/removed, or architectural patterns evolve, proactively update the relevant file(s) in thedocs/directory to reflect the latest state.Conventions for writing project documentation as described in the documentation style guide
docs/**/*.md: Use British English based on the Oxford English Dictionary (en-oxendict) for documentation text.
The word "outwith" is acceptable in documentation.
Keep US spelling when used in an API, for examplecolor.
Use the Oxford comma in documentation text.
Treat company names as collective nouns in documentation (e.g., "Lille Industries are expanding").
Write headings in sentence case in documentation.
Use Markdown headings (#,##,###, etc.) in order without skipping levels.
Follow markdownlint recommendations for Markdown files.
Provide code blocks and lists using standard Markdown syntax.
Always provide a language identifier for fenced code blocks; useplaintextfor non-code text.
Use-as the first level bullet and renumber lists when items change.
Prefer inline links using[text](url)or angle brackets around the URL; avoid reference-style links like[foo][bar].
Ensure blank lines before and after bulleted lists and fenced blocks in Markdown.
Ensure tables have a delimiter line below the header row in Markdown.
Expand any uncommon acronym on first use, for example, Continuous Integration (CI).
Wrap paragraphs at 80 columns in documentation.
Wrap code at 120 columns in documentation.
Do not wrap tables in documentation.
Use sequentially numbered footnotes referenced with[^1]and place definitions at the end of the file.
Where it adds clarity, include Mermaid diagrams in documentation.
When embedding figures, useand provide concise ...
Files:
docs/observability-operability-and-maturity.md
**/*.md
📄 CodeRabbit Inference Engine (AGENTS.md)
**/*.md: Documentation must use en-GB-oxendict spelling and grammar, except for the naming of the "LICENSE" file.
Validate Markdown files usingmake markdownlint.
Runmake fmtafter any documentation changes to format all Markdown files and fix table markup.
Validate Mermaid diagrams in Markdown files by runningmake nixie.
Markdown paragraphs and bullet points must be wrapped at 80 columns.
Code blocks in Markdown must be wrapped at 120 columns.
Tables and headings in Markdown must not be wrapped.
Use dashes (-) for list bullets in Markdown.
Use GitHub-flavoured Markdown footnotes ([^1]) for references and footnotes.
Files:
docs/observability-operability-and-maturity.md
⚙️ CodeRabbit Configuration File
**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")
- Use en-GB-oxendict (-ize / -our) spelling and grammar
- Paragraphs and bullets must be wrapped to 80 columns, except where a long URL would prevent this (in which case, silence MD013 for that line)
- Code blocks should be wrapped to 120 columns.
- Headings must not be wrapped.
- Documents must start with a level 1 heading
- Headings must correctly increase or decrease by no more than one level at a time
- Use GitHub-flavoured Markdown style for footnotes and endnotes.
- Numbered footnotes must be numbered by order of appearance in the document.
Files:
docs/observability-operability-and-maturity.md
docs/**/*.{md,rs}
📄 CodeRabbit Inference Engine (docs/multi-packet-and-streaming-responses-design.md)
docs/**/*.{md,rs}: The official documentation and examples must exclusively use the declarativeResponsemodel for handler responses.
The async-stream pattern must be documented as the canonical approach for dynamic stream generation.
Files:
docs/observability-operability-and-maturity.md
🧬 Code Graph Analysis (1)
src/server.rs (1)
src/extractor.rs (1)
peer_addr(362-362)
⏰ Context from checks skipped due to timeout of 240000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build-test
🔇 Additional comments (6)
Cargo.toml (1)
27-27: LGTM: Proper dependency addition.The
tracing-subscriberdependency follows the coding guidelines by using a caret requirement and supports the structured logging migration.src/main.rs (1)
6-8: LGTM: Proper tracing subscriber initialization.The placement and documentation of
tracing_subscriber::fmt::init()correctly supports the structured logging migration whilst providing clear guidance for library users.docs/observability-operability-and-maturity.md (1)
37-43: LGTM: Clear subscriber setup instructions.The documentation properly instructs users on tracing subscriber initialization and clearly explains the consequences of omitting this step.
src/server.rs (3)
443-444: LGTM: Enhanced accept error logging.The structured logging with
local_addrcontext provides valuable debugging information and follows proper tracing practices.
507-507: LGTM: Peer address retrieval for logging context.Obtaining the peer address early enables consistent contextual logging throughout the connection processing.
513-513: LGTM: Contextual preamble error logging.The structured logging includes both error details and peer address context, addressing the previous review feedback effectively.
|
|
||
| #[derive(bincode::Decode, bincode::Encode)] | ||
| #[expect(dead_code, reason = "used only in documentation example")] | ||
| #[allow(dead_code)] |
There was a problem hiding this comment.
Revert this lint attribute change.
The coding guidelines explicitly forbid #[allow] and require #[expect(lint, reason = "...")] instead. The original code was compliant and should be restored.
-#[allow(dead_code)]
+#[expect(dead_code, reason = "used only in documentation example")]📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| #[allow(dead_code)] | |
| #[expect(dead_code, reason = "used only in documentation example")] |
🤖 Prompt for AI Agents
In examples/metadata_routing.rs at line 63, revert the #[allow(dead_code)]
attribute back to the original lint directive using #[expect(lint, reason =
"...")] as per coding guidelines. Remove the #[allow(dead_code)] and replace it
with the appropriate #[expect] attribute including a clear reason for the lint
expectation to maintain compliance.
| /// Test helper preamble carrying no data. | ||
| #[derive(Debug, Clone, PartialEq, Encode, Decode)] | ||
| #[expect(dead_code, reason = "test helper for unused preamble type")] | ||
| #[allow(dead_code)] |
There was a problem hiding this comment.
Revert this lint attribute change.
The coding guidelines explicitly forbid #[allow] and require #[expect(lint, reason = "...")] instead. Restore the compliant attribute.
-#[allow(dead_code)]
+#[expect(dead_code)]Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In src/server.rs at line 561, revert the #[allow(dead_code)] attribute to comply
with coding guidelines by replacing it with #[expect(dead_code, reason =
"...")], providing a clear reason for the expectation instead of allowing the
lint.
Summary
eprintln!calls insrc/server.rsfortracingmacrosTesting
make lintmake testhttps://chatgpt.com/codex/tasks/task_e_688bc75e4c7c8322b74b2d2aa0f49be8
Summary by Sourcery
Enhancements: