@@ -171,19 +171,26 @@ func (w *staticSlidingWindow) reportMetrics() {
171171 for {
172172 select {
173173 case <- ticker .C :
174- watermark := w .Watermark ()
175-
176- // ProcessTime can be seen as the duration that event are in the queue.
177- seconds := time .Since (watermark .ProcessTime ).Seconds ()
178- if seconds > ProcessDelayWarningThreshold {
179- log .Warnf ("[sliding_window] item not ack after %f seconds. %s" , seconds , w .nextItemToCommit )
174+ waitingCnt := len (w .waitingItemC )
175+
176+ if waitingCnt > 0 {
177+ watermark := w .Watermark ()
178+
179+ // ProcessTime can be seen as the duration that event are in the queue.
180+ seconds := time .Since (watermark .ProcessTime ).Seconds ()
181+ if seconds > ProcessDelayWarningThreshold {
182+ log .Warnf ("[sliding_window] item not ack after %f seconds. %s" , seconds , w .nextItemToCommit )
183+ }
184+ metrics .End2EndProcessTimeHistogram .WithLabelValues (env .PipelineName ).Observe (seconds )
185+
186+ // EventTime can be seen as the end to end duration of event process time.
187+ metrics .End2EndEventTimeHistogram .WithLabelValues (env .PipelineName ).Observe (time .Since (watermark .EventTime ).Seconds ())
188+ } else {
189+ metrics .End2EndProcessTimeHistogram .WithLabelValues (env .PipelineName ).Observe (0 )
190+ metrics .End2EndEventTimeHistogram .WithLabelValues (env .PipelineName ).Observe (0 )
180191 }
181- metrics .End2EndProcessTimeHistogram .WithLabelValues (env .PipelineName ).Observe (seconds )
182-
183- // EventTime can be seen as the end to end duration of event process time.
184- metrics .End2EndEventTimeHistogram .WithLabelValues (env .PipelineName ).Observe (time .Since (watermark .EventTime ).Seconds ())
185192
186- metrics .QueueLength .WithLabelValues (env .PipelineName , "sliding-window-waiting-chan" , w .name ).Set (float64 (len ( w . waitingItemC ) ))
193+ metrics .QueueLength .WithLabelValues (env .PipelineName , "sliding-window-waiting-chan" , w .name ).Set (float64 (waitingCnt ))
187194 metrics .QueueLength .WithLabelValues (env .PipelineName , "sliding-window-ready-chan" , w .name ).Set (float64 (len (w .readyC )))
188195 metrics .QueueLength .WithLabelValues (env .PipelineName , "sliding-window-ready-heap" , w .name ).Set (float64 (atomic .LoadInt64 (& w .heapSize )))
189196
0 commit comments