Skip to content

Add KafkaErrorDetector for producer/consumer error detection#9

Merged
AbaSheger merged 2 commits into
AbaSheger:mainfrom
sandeshgorde:main
May 6, 2026
Merged

Add KafkaErrorDetector for producer/consumer error detection#9
AbaSheger merged 2 commits into
AbaSheger:mainfrom
sandeshgorde:main

Conversation

@sandeshgorde
Copy link
Copy Markdown
Contributor

@sandeshgorde sandeshgorde commented May 6, 2026

Closes #1

Added KafkaErrorDetector to detect common Kafka producer/consumer failures in Spring Boot logs.

Changes

  • KafkaErrorDetector.java — detects ProducerFencedException, CommitFailedException, WakeupException, org.apache.kafka.common.errors at ERROR severity
  • IssueClassifier.java — registered new detector
  • AllDetectorsTest.java — 5 tests covering all patterns + negative case.

Summary by CodeRabbit

  • New Features

    • Added Kafka error detection that identifies and reports Kafka-related runtime errors with actionable remediation guidance.
    • Detects specific Kafka exceptions including producer, consumer group, and broker-related issues.
  • Tests

    • Added comprehensive test coverage for Kafka error detection scenarios.

Detects:
- ProducerFencedException
- CommitFailedException
- WakeupException
- org.apache.kafka.common.errors

Severity: ERROR
Good first issue contribution (AbaSheger#1).
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

Warning

Rate limit exceeded

@sandeshgorde has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 7 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 11e23c8f-e55b-4a29-8b81-2d1af498c6b7

📥 Commits

Reviewing files that changed from the base of the PR and between 4db9d9c and f87eb98.

📒 Files selected for processing (1)
  • src/main/java/com/stacklens/detector/KafkaErrorDetector.java
📝 Walkthrough

Walkthrough

A new KafkaErrorDetector is implemented to identify Kafka runtime errors matching ProducerFencedException, CommitFailedException, WakeupException, and org.apache.kafka.common.errors patterns. The detector is registered in IssueClassifier and covered by comprehensive test cases.

Changes

Kafka Error Detection

Layer / File(s) Summary
Detector Implementation
src/main/java/com/stacklens/detector/KafkaErrorDetector.java
New detector class implements IssueDetector, scans log lines for Kafka error signatures (ProducerFencedException, CommitFailedException, WakeupException, org.apache.kafka.common.errors), and returns an Issue with type "KafkaError", severity ERROR, descriptive message, and remediation hints.
Classifier Registration
src/main/java/com/stacklens/classifier/IssueClassifier.java
KafkaErrorDetector is registered in the ERROR-severity detector list immediately after TransactionErrorDetector.
Tests
src/test/java/com/stacklens/detector/AllDetectorsTest.java
Five new test methods verify detection of ProducerFencedException, CommitFailedException, WakeupException, common Kafka errors, and confirm non-detection of clean lines.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • AbaSheger/stacklens#7: Both PRs add a new IssueDetector implementation and register it in IssueClassifier's constructor
  • AbaSheger/stacklens#8: Both PRs add ERROR-severity detectors and register them in IssueClassifier

Poem

🐰 Kafka errors hop no more,
A new detector at the door,
Fenced and wakeful, caught with care,
Stacklens debugs with rabbit flair! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding KafkaErrorDetector for Kafka error detection.
Description check ✅ Passed The PR description covers the primary objective and lists all changed files with clear explanations of modifications.
Linked Issues check ✅ Passed All requirements from issue #1 are met: all four patterns detected, ERROR severity applied, KafkaErrorDetector implemented and registered.
Out of Scope Changes check ✅ Passed All code changes are directly related to Kafka error detection implementation and testing; no out-of-scope modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

🧹 Nitpick comments (1)
src/test/java/com/stacklens/detector/AllDetectorsTest.java (1)

263-290: ⚡ Quick win

Strengthen Kafka positive tests with type/severity assertions.

These tests currently only check isPresent(). Please also assert getType() (and ideally getSeverity()) so regressions in emitted metadata are caught, not just matching behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/test/java/com/stacklens/detector/AllDetectorsTest.java` around lines 263
- 290, Update the three Kafka tests
(kafkaErrorDetector_detectsCommitFailedException,
kafkaErrorDetector_detectsWakeupException,
kafkaErrorDetector_detectsKafkaCommonErrors) to not only assert
result.isPresent() but also validate the emitted Issue metadata: call
result.get() and assert its getType() equals the expected Kafka type emitted by
KafkaErrorDetector (use the detector's declared type constant or literal used by
KafkaErrorDetector) and assert getSeverity() equals the expected severity value
(use the severity constant from KafkaErrorDetector or the Severity enum value
the detector is intended to produce). This ensures the tests verify
Issue.getType() and Issue.getSeverity() in addition to presence.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/test/java/com/stacklens/detector/AllDetectorsTest.java`:
- Around line 263-290: Update the three Kafka tests
(kafkaErrorDetector_detectsCommitFailedException,
kafkaErrorDetector_detectsWakeupException,
kafkaErrorDetector_detectsKafkaCommonErrors) to not only assert
result.isPresent() but also validate the emitted Issue metadata: call
result.get() and assert its getType() equals the expected Kafka type emitted by
KafkaErrorDetector (use the detector's declared type constant or literal used by
KafkaErrorDetector) and assert getSeverity() equals the expected severity value
(use the severity constant from KafkaErrorDetector or the Severity enum value
the detector is intended to produce). This ensures the tests verify
Issue.getType() and Issue.getSeverity() in addition to presence.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 14ebf4f5-e2c6-4859-9be6-0ed67e8ed4e8

📥 Commits

Reviewing files that changed from the base of the PR and between f374a42 and 4db9d9c.

📒 Files selected for processing (3)
  • src/main/java/com/stacklens/classifier/IssueClassifier.java
  • src/main/java/com/stacklens/detector/KafkaErrorDetector.java
  • src/test/java/com/stacklens/detector/AllDetectorsTest.java

Added class-level and method-level Javadoc to fix CodeRabbit's
docstring coverage warning. Follows existing detector patterns.
Copy link
Copy Markdown
Owner

Reviewed the Kafka detector changes. The implementation is scoped to Kafka producer/consumer error patterns, the detector is registered in the classifier, and CI is passing on the latest commit. There is one minor follow-up suggestion to strengthen a few positive tests with type/severity assertions, but it is not blocking this merge. Thanks for the contribution.

@AbaSheger AbaSheger merged commit ae7282c into AbaSheger:main May 6, 2026
3 checks passed
Copy link
Copy Markdown
Owner

Thanks again for adding the Kafka error detector. I verified the merged project locally with mvn clean verify; all 88 tests passed and the build completed successfully.

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.

[Detector] Add Kafka producer/consumer error detection

2 participants