@@ -5,7 +5,7 @@ use crate::error::Error;
55use crate :: message:: Message ;
66use crate :: metrics:: {
77 PIPELINE_PARTITION_NAME_LABEL , monovertex_metrics, mvtx_forward_metric_labels,
8- pipeline_metric_labels, pipeline_metrics,
8+ pipeline_drop_metric_labels , pipeline_metric_labels, pipeline_metrics,
99} ;
1010use crate :: sinker:: actor:: { SinkActorMessage , SinkActorResponse } ;
1111use numaflow_kafka:: sink:: KafkaSink ;
@@ -453,7 +453,6 @@ impl SinkWriter {
453453 dropped_messages_size : usize ,
454454 write_start_time : time:: Instant ,
455455 ) {
456- // TODO: add metric for dropped messages because of retry strategy
457456 if is_mono_vertex ( ) {
458457 monovertex_metrics ( )
459458 . sink
@@ -465,6 +464,14 @@ impl SinkWriter {
465464 . write_total
466465 . get_or_create ( mvtx_forward_metric_labels ( ) )
467466 . inc_by ( ( messages_count - fallback_messages_count - dropped_messages_count) as u64 ) ;
467+
468+ if dropped_messages_count > 0 {
469+ monovertex_metrics ( )
470+ . sink
471+ . dropped_total
472+ . get_or_create ( mvtx_forward_metric_labels ( ) )
473+ . inc_by ( dropped_messages_count as u64 ) ;
474+ }
468475 } else {
469476 let mut labels = pipeline_metric_labels ( VERTEX_TYPE_SINK ) . clone ( ) ;
470477 labels. push ( (
@@ -487,6 +494,18 @@ impl SinkWriter {
487494 . write_processing_time
488495 . get_or_create ( & labels)
489496 . observe ( write_start_time. elapsed ( ) . as_micros ( ) as f64 ) ;
497+
498+ if dropped_messages_count > 0 {
499+ pipeline_metrics ( )
500+ . forwarder
501+ . drop_total
502+ . get_or_create ( & pipeline_drop_metric_labels (
503+ VERTEX_TYPE_SINK ,
504+ get_vertex_name ( ) ,
505+ "Retries exhausted in the Sink" ,
506+ ) )
507+ . inc_by ( dropped_messages_count as u64 ) ;
508+ }
490509 }
491510 }
492511
0 commit comments