Conversation
|
Caution Review failedThe pull request is closed. WalkthroughReplaced unconditional console logging in the Kafka health-check with environment-gated checks using Changes
Sequence Diagram(s)(omitted — changes are logging guards only; control flow is unchanged) Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
health-check/services/kafka.js (1)
26-27: Inconsistent logging: This console.log is not gated by debug mode.All other logging statements in this file are wrapped with the
HEALTH_CHECK_DEBUG_MODEcheck, but this line remains unconditional. This appears to be an oversight.Apply this diff to maintain consistency:
- console.log(`[Kafka Health Check] Topic '${topicName}' exists ✅`) + if (process.env.HEALTH_CHECK_DEBUG_MODE == 'true') { + console.log(`[Kafka Health Check] Topic '${topicName}' exists ✅`) + }
🧹 Nitpick comments (2)
health-check/services/kafka.js (2)
18-20: Consider extracting the debug mode check to reduce duplication.The condition
process.env.HEALTH_CHECK_DEBUG_MODE == 'true'is repeated 11 times throughout the file. This creates maintenance overhead and makes the code less readable.Apply this diff to extract the condition to a helper variable at the top of the check function:
async function check(kafkaUrl, topicName, groupId, sendReceive = false) { return new Promise(async (resolve) => { + const isDebugMode = process.env.HEALTH_CHECK_DEBUG_MODE === 'true' const pidSuffix = `-${process.pid}`Then replace all occurrences of
if (process.env.HEALTH_CHECK_DEBUG_MODE == 'true')withif (isDebugMode)throughout the function. The same pattern can be applied toensureTopicExistsfunction.Also applies to: 30-32, 35-37, 69-71, 77-79, 86-88, 105-107, 122-124, 132-134, 140-142, 147-149
18-20: Use strict equality (===) instead of loose equality (==).The debug mode checks use
==for comparison. Using===is a JavaScript best practice for type-safe comparison and makes the intent more explicit.Replace
== 'true'with=== 'true'in all debug mode checks.Also applies to: 30-32, 35-37, 69-71, 77-79, 86-88, 105-107, 122-124, 132-134, 140-142, 147-149
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
health-check/services/kafka.js(5 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: MallanagoudaB
PR: ELEVATE-Project/utils#342
File: health-check/services/kafka.js:49-54
Timestamp: 2025-08-20T10:33:46.359Z
Learning: In the ELEVATE-Project/utils health-check module, validation for Kafka configuration including groupId is performed in the parent file (health-check/index.js) in the validateHealthConfig function, not in the individual service files like health-check/services/kafka.js.
Learnt from: MallanagoudaB
PR: ELEVATE-Project/utils#342
File: health-check/services/kafka.js:49-54
Timestamp: 2025-08-20T10:33:46.359Z
Learning: In the ELEVATE-Project/utils health-check module, when updating function signatures to add new parameters, both the service file and the parent file (health-check/index.js) that calls the function need to be updated to pass all required parameters.
📚 Learning: 2025-08-20T10:33:46.359Z
Learnt from: MallanagoudaB
PR: ELEVATE-Project/utils#342
File: health-check/services/kafka.js:49-54
Timestamp: 2025-08-20T10:33:46.359Z
Learning: In the ELEVATE-Project/utils health-check module, validation for Kafka configuration including groupId is performed in the parent file (health-check/index.js) in the validateHealthConfig function, not in the individual service files like health-check/services/kafka.js.
Applied to files:
health-check/services/kafka.js
📚 Learning: 2025-08-20T10:33:46.359Z
Learnt from: MallanagoudaB
PR: ELEVATE-Project/utils#342
File: health-check/services/kafka.js:49-54
Timestamp: 2025-08-20T10:33:46.359Z
Learning: In the ELEVATE-Project/utils health-check module, when updating function signatures to add new parameters, both the service file and the parent file (health-check/index.js) that calls the function need to be updated to pass all required parameters.
Applied to files:
health-check/services/kafka.js
🧬 Code graph analysis (1)
health-check/services/kafka.js (1)
health-check/index.js (1)
kafka(37-37)
🔇 Additional comments (1)
health-check/services/kafka.js (1)
18-20: Verify that gating error logs behind debug mode is intentional.All error logging (console.error) is now conditional on
HEALTH_CHECK_DEBUG_MODE. This means that in production, when health checks fail, no error messages will be logged unless the debug flag is explicitly enabled. This could make troubleshooting production issues more difficult.Please confirm this is the desired behavior, or consider keeping critical error logs always enabled while only gating informational/success messages.
Also applies to: 69-71, 122-124, 140-142, 147-149
Summary by CodeRabbit