Skip to content

added-debug-for-logs#371

Merged
VISHNUDAS-tunerlabs merged 4 commits intomasterfrom
KafkaDebug
Oct 30, 2025
Merged

added-debug-for-logs#371
VISHNUDAS-tunerlabs merged 4 commits intomasterfrom
KafkaDebug

Conversation

@MallanagoudaB
Copy link
Copy Markdown
Collaborator

@MallanagoudaB MallanagoudaB commented Oct 30, 2025

Summary by CodeRabbit

  • Chores
    • Kafka health-check debug logging is now controllable via an environment setting, allowing debug output to be enabled or silenced without changing behavior.
    • Package version updated to 0.0.7 to reflect the change.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Oct 30, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Replaced unconditional console logging in the Kafka health-check with environment-gated checks using process.env.HEALTH_CHECK_DEBUG_MODE === 'true'. Bumped package version from 0.0.6 to 0.0.7. No functional or public API changes.

Changes

Cohort / File(s) Summary
Debug logging guard
health-check/services/kafka.js
Wrapped all console log statements with if (process.env.HEALTH_CHECK_DEBUG_MODE === 'true') conditionals (metadata errors, topic checks/creation, connection, send/receive, timeouts, consumer errors, cleanup messages). No logic or exports changed.
Package version bump
health-check/package.json
Updated version from 0.0.6 to 0.0.7. No other metadata, scripts, or dependency changes.

Sequence Diagram(s)

(omitted — changes are logging guards only; control flow is unchanged)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Primary focus: confirm each console statement was wrapped with the exact conditional process.env.HEALTH_CHECK_DEBUG_MODE === 'true'.
  • Check that no statements with side effects were moved into or out of guarded blocks and that cleanup/error paths remain intact.

Possibly related PRs

  • added-debug-for-logs #371 — also gates console logs in health-check/services/kafka.js behind HEALTH_CHECK_DEBUG_MODE/DEBUG_MODE.
  • kafka-topic-change #341 — modifies the same health-check/services/kafka.js check function (topic-name handling), potentially interacting with logged messages or flow.

Suggested reviewers

  • VISHNUDAS-tunerlabs

Poem

🐰 Logs now nap until flags invite,
A quiet check beneath the night,
When HEALTH_CHECK_DEBUG_MODE says "true",
The Kafka whispers come anew.
Hop, debug hop, and all is bright.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "added-debug-for-logs" is directly related to the main change in the pull request. The changeset wraps console logging statements with a conditional check for the HEALTH_CHECK_DEBUG_MODE environment variable, effectively adding debug-controlled logging throughout the Kafka health-check service. The title accurately captures this primary objective of adding debug gating to the logging behavior. The title is concise and conveys meaningful information about the nature of the change without being overly broad or vague.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

📜 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 dacd654 and c0a948e.

📒 Files selected for processing (2)
  • health-check/package.json (1 hunks)
  • health-check/services/kafka.js (4 hunks)

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@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

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_MODE check, 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') with if (isDebugMode) throughout the function. The same pattern can be applied to ensureTopicExists function.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7f78f73 and dacd654.

📒 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

@VISHNUDAS-tunerlabs VISHNUDAS-tunerlabs merged commit 0dba3f4 into master Oct 30, 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.

2 participants