@@ -35,22 +35,78 @@ public class IngestionStats {
3535 protected static final String LEADER_RECORDS_PRODUCED_METRIC_NAME = "leader_records_produced" ;
3636 protected static final String LEADER_BYTES_PRODUCED_METRIC_NAME = "leader_bytes_produced" ;
3737 protected static final String SUBSCRIBE_ACTION_PREP_LATENCY = "subscribe_action_prep_latency" ;
38- protected static final String CONSUMED_RECORD_END_TO_END_PROCESSING_LATENCY =
39- "consumed_record_end_to_end_processing_latency" ;
4038 protected static final String UPDATE_IGNORED_DCR = "update_ignored_dcr" ;
4139 protected static final String TOTAL_DCR = "total_dcr" ;
4240 protected static final String TOTAL_DUPLICATE_KEY_UPDATE_COUNT = "total_duplicate_key_update_count" ;
43-
4441 protected static final String TIMESTAMP_REGRESSION_DCR_ERROR = "timestamp_regression_dcr_error" ;
4542 protected static final String OFFSET_REGRESSION_DCR_ERROR = "offset_regression_dcr_error" ;
4643 protected static final String TOMBSTONE_CREATION_DCR = "tombstone_creation_dcr" ;
44+
45+ /**
46+ * Consumer metric: Measures the total time from when a record starts being processed (after polling from Kafka and
47+ * schema checks) until it completes all processing stages. This includes leader preprocessing, producing to local
48+ * Kafka (for leaders), queueing to drainer, drainer processing (persisting to storage), and offset updates.
49+ */
50+ protected static final String CONSUMED_RECORD_END_TO_END_PROCESSING_LATENCY =
51+ "consumed_record_end_to_end_processing_latency" ;
52+ /**
53+ * Leader metric: Measures the latency from when a nearline producer originally produced a message (with its producer
54+ * timestamp) to when that message is successfully written to the local broker's version topic by the leader.
55+ */
4756 public static final String NEARLINE_PRODUCER_TO_LOCAL_BROKER_LATENCY = "nearline_producer_to_local_broker_latency" ;
48- public static final String NEARLINE_LOCAL_BROKER_TO_READY_TO_SERVE_LATENCY =
49- "nearline_local_broker_to_ready_to_serve_latency" ;
57+
58+ /**
59+ * Leader metric: Measures the latency from when a producer created a message (producer timestamp) to when the
60+ * source broker (remote region Kafka) received it.
61+ */
62+ public static final String PRODUCER_TO_SOURCE_BROKER_LATENCY = "producer_to_source_broker_latency" ;
63+
64+ /**
65+ * Leader metric: Measures the latency from when the source broker (remote region Kafka) received a message to when
66+ * the leader consumer fetched it.
67+ */
68+ public static final String SOURCE_BROKER_TO_LEADER_CONSUMER_LATENCY = "source_broker_to_leader_consumer_latency" ;
69+
70+ /**
71+ * Follower metric: Measures the latency from when the leader produced a message to when the local broker
72+ * (local region Kafka) received it.
73+ */
74+ public static final String PRODUCER_TO_LOCAL_BROKER_LATENCY = "producer_to_local_broker_latency" ;
75+
76+ /**
77+ * Follower metric: Measures the latency from when the local broker (local region Kafka) received a message to when
78+ * the follower consumer fetched it.
79+ */
80+ public static final String LOCAL_BROKER_TO_FOLLOWER_CONSUMER_LATENCY = "local_broker_to_follower_consumer_latency" ;
81+
82+ /**
83+ * Leader metric: Measures the time from when a produce call is made to when the producer callback is invoked,
84+ * indicating how long Kafka took to write the message to the broker and invoke the callback.
85+ */
86+ public static final String LEADER_PRODUCER_COMPLETION_LATENCY = "leader_producer_completion_latency" ;
87+
5088 public static final String IDLE_TIME = "idle_time" ;
89+ /**
90+ * Leader metric: Measures the time spent within the leader's producer callback processing after a message is
91+ * successfully produced to the local broker. This includes chunking processing, producing to drainer buffer service,
92+ * producing deprecated chunk deletions, and recording stats.
93+ */
5194 public static final String PRODUCER_CALLBACK_LATENCY = "producer_callback_latency" ;
95+ /**
96+ * Leader metric: Measures the time from when keys are locked for a batch of records to just before producing to Kafka.
97+ * When batch processing is enabled: includes batch processing (with partial update operations), record validation,
98+ * and for real-time topics, recording hybrid consumption stats.
99+ * When batch processing is disabled: includes only record validation and stats recording; partial update happens later.
100+ */
52101 public static final String LEADER_PREPROCESSING_LATENCY = "leader_preprocessing_latency" ;
102+ /**
103+ * Drainer metric: Measures the time spent on lightweight preprocessing tasks before heavy message processing begins.
104+ * This includes recording write path latency stats (producer-to-broker, broker-to-consumer), drainer message
105+ * validation, and reporting batch end of incremental push status. Recorded at the start of internalProcessConsumerRecord,
106+ * before control message or data message processing.
107+ */
53108 public static final String INTERNAL_PREPROCESSING_LATENCY = "internal_preprocessing_latency" ;
109+
54110 public static final String BATCH_PROCESSING_REQUEST = "batch_processing_request" ;
55111 public static final String BATCH_PROCESSING_REQUEST_SIZE = "batch_processing_request_size" ;
56112 public static final String BATCH_PROCESSING_REQUEST_RECORDS = "batch_processing_request_records" ;
@@ -84,7 +140,6 @@ public class IngestionStats {
84140 private final WritePathLatencySensor subscribePrepLatencySensor ;
85141 private final WritePathLatencySensor consumedRecordEndToEndProcessingLatencySensor ;
86142 private final WritePathLatencySensor nearlineProducerToLocalBrokerLatencySensor ;
87- private final WritePathLatencySensor nearlineLocalBrokerToReadyToServeLatencySensor ;
88143 private final WritePathLatencySensor producerCallBackLatency ;
89144 private final WritePathLatencySensor leaderPreprocessingLatency ;
90145 private final WritePathLatencySensor internalPreprocessingLatency ;
@@ -154,25 +209,21 @@ public IngestionStats(VeniceServerConfig serverConfig) {
154209 totalDuplicateKeyUpdateCountSensor .add (TOTAL_DUPLICATE_KEY_UPDATE_COUNT , totalDuplicateKeyUpdateCount );
155210
156211 producerSourceBrokerLatencySensor =
157- new WritePathLatencySensor (localMetricRepository , METRIC_CONFIG , "producer_to_source_broker_latency" );
212+ new WritePathLatencySensor (localMetricRepository , METRIC_CONFIG , PRODUCER_TO_SOURCE_BROKER_LATENCY );
158213 sourceBrokerLeaderConsumerLatencySensor =
159- new WritePathLatencySensor (localMetricRepository , METRIC_CONFIG , "source_broker_to_leader_consumer_latency" );
214+ new WritePathLatencySensor (localMetricRepository , METRIC_CONFIG , SOURCE_BROKER_TO_LEADER_CONSUMER_LATENCY );
160215 producerLocalBrokerLatencySensor =
161- new WritePathLatencySensor (localMetricRepository , METRIC_CONFIG , "producer_to_local_broker_latency" );
216+ new WritePathLatencySensor (localMetricRepository , METRIC_CONFIG , PRODUCER_TO_LOCAL_BROKER_LATENCY );
162217 localBrokerFollowerConsumerLatencySensor =
163- new WritePathLatencySensor (localMetricRepository , METRIC_CONFIG , "local_broker_to_follower_consumer_latency" );
218+ new WritePathLatencySensor (localMetricRepository , METRIC_CONFIG , LOCAL_BROKER_TO_FOLLOWER_CONSUMER_LATENCY );
164219 leaderProducerCompletionLatencySensor =
165- new WritePathLatencySensor (localMetricRepository , METRIC_CONFIG , "leader_producer_completion_latency" );
220+ new WritePathLatencySensor (localMetricRepository , METRIC_CONFIG , LEADER_PRODUCER_COMPLETION_LATENCY );
166221 subscribePrepLatencySensor =
167222 new WritePathLatencySensor (localMetricRepository , METRIC_CONFIG , SUBSCRIBE_ACTION_PREP_LATENCY );
168223 consumedRecordEndToEndProcessingLatencySensor =
169224 new WritePathLatencySensor (localMetricRepository , METRIC_CONFIG , CONSUMED_RECORD_END_TO_END_PROCESSING_LATENCY );
170225 nearlineProducerToLocalBrokerLatencySensor =
171226 new WritePathLatencySensor (localMetricRepository , METRIC_CONFIG , NEARLINE_PRODUCER_TO_LOCAL_BROKER_LATENCY );
172- nearlineLocalBrokerToReadyToServeLatencySensor = new WritePathLatencySensor (
173- localMetricRepository ,
174- METRIC_CONFIG ,
175- NEARLINE_LOCAL_BROKER_TO_READY_TO_SERVE_LATENCY );
176227 producerCallBackLatency =
177228 new WritePathLatencySensor (localMetricRepository , METRIC_CONFIG , PRODUCER_CALLBACK_LATENCY );
178229 leaderPreprocessingLatency =
@@ -439,22 +490,10 @@ public double getNearlineProducerToLocalBrokerLatencyMax() {
439490 return unAvailableToZero (nearlineProducerToLocalBrokerLatencySensor .getMax ());
440491 }
441492
442- public double getNearlineLocalBrokerToReadyToServeLatencyAvg () {
443- return unAvailableToZero (nearlineLocalBrokerToReadyToServeLatencySensor .getAvg ());
444- }
445-
446- public double getNearlineLocalBrokerToReadyToServeLatencyMax () {
447- return unAvailableToZero (nearlineLocalBrokerToReadyToServeLatencySensor .getMax ());
448- }
449-
450493 public void recordNearlineProducerToLocalBrokerLatency (double value , long currentTimeMs ) {
451494 nearlineProducerToLocalBrokerLatencySensor .record (value , currentTimeMs );
452495 }
453496
454- public void recordNearlineLocalBrokerToReadyToServeLatency (double value , long currentTimeMs ) {
455- nearlineLocalBrokerToReadyToServeLatencySensor .record (value , currentTimeMs );
456- }
457-
458497 public void recordIdleTime (long value ) {
459498 idleTimeSensor .record (value );
460499 }
0 commit comments