Skip to content

[kafka] Add request metrics with per-table Produce breakdown - #4896

Open
gyang94 wants to merge 3 commits into
apache:mainfrom
gyang94:codex/kafka-request-metrics
Open

gyang94 wants to merge 3 commits into
apache:mainfrom
gyang94:codex/kafka-request-metrics

Conversation

@gyang94

@gyang94 gyang94 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Generative AI disclosure: Yes — OpenAI Codex (GPT-6).

Purpose

Related issue: #4185.

Kafka listeners currently lack request-level throughput, failure, latency, and in-flight metrics. Add these metrics by listener and API, with an additional database/table breakdown for Produce requests.

Brief change log

  • Add requestsPerSecond, failedRequestsPerSecond, requestQueueTimeMs, requestProcessTimeMs, responseQueueTimeMs, totalTimeMs, and inFlightRequests.
  • Track asynchronous processing, ordered response queues, write completion, acks=0, and cancellation without double counting.
  • Resolve Produce topic aliases to canonical database/table names and count each involved table once. Attribute partition failures to the affected tables; request-wide failures count against all involved tables.
  • Reuse existing local table metric groups so table metrics are removed with the last local bucket. Table latency samples describe the entire request involving that table.

Tests

KafkaMetadataITCase now waits for topic and partition metadata readiness after creating tables before running the custom-default-database alias assertions. All original protocol-version, topic ID, and database non-recreation checks are retained.

KafkaRequestMetricsTest uses one fixture and five test methods (nine cases) to cover timing and write completion, table aliases and partial failures, acks=0, cancellation, processing/serialization failures, and table metric cleanup. A single metrics integration test in KafkaProtocolPluginITCase verifies both API and table registration through a real Netty listener.

Validated on JDK 11, including the full KafkaMetadataITCase integration suite:

mvn -o -pl fluss-kafka -am verify \
  '-Dtest=*Kafka*Test,ApiVersionsHandlerTest,JsonToFlussConvertersTest,TabletServerMetricGroupTest,TableMetricGroupTest,KafkaProtocolPluginITCase,KafkaMetadataITCase' \
  -Dsurefire.failIfNoSpecifiedTests=false

Result: BUILD SUCCESS. The selected Kafka suite ran 348 tests, and the server suite ran 13 tests, with no failures, errors, or skips. Spotless and Checkstyle passed.

API and Format

Adds a backward-compatible default overload of NetworkProtocolPlugin.createChannelHandler to supply the server metric group, and a lookup for existing local table metric groups. No Kafka wire protocol or storage format changes.

Documentation

Updated the Kafka compatibility guide with metric names, scopes, timing boundaries, acks=0 behavior, and per-table counting and lifecycle semantics.

gyang94 and others added 3 commits October 27, 2026 00:45
Track request rates, failures, queue and processing latency, response
queue latency, total latency, and in-flight requests by listener and API.
Attribute Produce metrics to canonical database/table names and share
the lifecycle of locally hosted table metrics.

Handle partial failures, acks=0, response ordering, and cancellation
without duplicate counts. Document the metric boundaries and cover
request timing, table attribution, cleanup, and listener registration.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 512/512
AI-Contributed/UT: 947/947
Share the metric-group cache and track request progress with one stage
and one stage timestamp. Consolidate failure handling and remove unused
construction paths without changing metric semantics.

Merge API and table metric tests into one fixture, retaining core timing,
failure attribution, acks=0, cancellation, cleanup, and listener wiring.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 111/111
AI-Contributed/UT: 915/915
Wait for topic and partition metadata to report success after creating
tables, since online replicas do not guarantee a synchronized Kafka
metadata cache. Keep the protocol-version, alias, topic ID, and database
non-recreation assertions unchanged.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 0/0
AI-Contributed/UT: 11/11
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