Auto-register client metrics (consumer lag, throughput, broker latency) #261
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 635 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.386
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #261"
general
weight: 0.35
FranzBusch
Summary
KafkaConfiguration.ConsumerMetrics/ProducerMetricsopt-in with an auto-registerKafkaMetricsConfigmodel..enabled()— prefixkafka, 5s interval). Tune with.enabled(prefix:updateInterval:); opt out with.disabled(zero overhead: no instruments, no stats polling). An explicitstatisticsIntervalMsstill wins.client_iddimension — the configuredclient.id, else librdkafka's unique handle name (e.g.rdkafka#consumer-1) — so multiple clients in one process report separate series..statisticsevents and records the full set below, plus imperative delivery/commit/error hooks.Enabling
KafkaProducerConfig.metricsworks identically (emits underkafka.producer.).Consumer metrics (12)
All metrics carry
client_id; dims listed below are in addition to it. Meters report librdkafka's cumulative totals as-is.kafka.consumer.lag(Gauge, dims: topic, partition) — per-partition lagkafka.consumer.lag.max(Gauge) — max lag across partitionskafka.consumer.queue.operations(Gauge)kafka.consumer.messages.received(Meter)kafka.consumer.bytes.received(Meter)kafka.consumer.errors.total(Counter)kafka.consumer.rebalances(Meter, fromcgrp.rebalance_cnt)kafka.consumer.commits.total(Counter) — manual commitskafka.consumer.commits.failed(Counter)kafka.consumer.commit.duration(Timer)kafka.consumer.broker.rtt.{avg,p99,max}.ms(Gauge, dims: broker)kafka.consumer.broker.throttle.{avg,p99,max}.ms(Gauge, dims: broker)Producer metrics (14)
kafka.producer.queue.messages(Gauge)kafka.producer.queue.bytes(Gauge)kafka.producer.messages.sent(Meter)kafka.producer.bytes.sent(Meter)kafka.producer.batch.size.avg(Gauge)kafka.producer.delivery.success.total(Counter)kafka.producer.delivery.failure.total(Counter)kafka.producer.send.errors.total(Counter)kafka.producer.send.duration(Timer) — end-to-end acknowledgedsendAndAwaitkafka.producer.errors.total(Counter)kafka.producer.broker.rtt.{avg,p99,max}.ms(Gauge, dims: broker)kafka.producer.broker.throttle.{avg,p99,max}.ms(Gauge, dims: broker)kafka.producer.broker.queue.latency.{avg,p99,max}.ms(Gauge, dims: broker) —int_latencykafka.producer.broker.request.latency.{avg,p99,max}.ms(Gauge, dims: broker) —outbuf_latencyPer-broker latency windows are surfaced as pre-aggregated
avg/p99/maxgauges dimensioned by broker, normalized to milliseconds (the.mssuffix). librdkafka pre-aggregates them, so aTimerwould be incorrect.Breaking changes (semver: major)
KafkaConfiguration.ConsumerMetrics/ProducerMetricsremoved.KafkaConsumerConfig.metrics/KafkaProducerConfig.metrics(and the deprecatedConfigurationequivalents) change type toKafkaMetricsConfig.config.metrics = .disabledto opt out).api-breakages.txtupdated.Motivation
The old API required users to construct and assign each
Gaugeindividually, which led to inconsistent naming, incomplete coverage by default, and no Counters/Timers. The auto-register model mirrors the Java client, which records metrics by default; the librdkafka-based Rust/Go/Python clients only expose raw statistics JSON. Consumer lag is the headline signal.Test plan
client_idfallback; default-on andstatistics.interval.msprecedence.send.duration, commit, stats-sampling, andmessages.receivedMeter metrics. Both metrics suites usewithMetricsFactory(_:_:)(task-local) so parallel suites don't clobber the globalMetricsSystem.-Xswiftc -warnings-as-errors(140 tests).