5757
5858 trDurationView * view.View
5959 prTRDurationView * view.View
60+ trCountView * view.View
6061 trTotalView * view.View
62+ runningTRsCountView * view.View
6163 runningTRsView * view.View
64+ runningTRsThrottledByQuotaCountView * view.View
65+ runningTRsThrottledByNodeCountView * view.View
6266 runningTRsThrottledByQuotaView * view.View
6367 runningTRsThrottledByNodeView * view.View
6468 runningTRsWaitingOnTaskResolutionCountView * view.View
@@ -74,14 +78,30 @@ var (
7478 "The pipelinerun's taskrun execution time in seconds" ,
7579 stats .UnitDimensionless )
7680
81+ trCount = stats .Float64 ("taskrun_count" ,
82+ "number of taskruns" ,
83+ stats .UnitDimensionless )
84+
7785 trTotal = stats .Float64 ("taskrun_total" ,
7886 "Number of taskruns" ,
7987 stats .UnitDimensionless )
8088
89+ runningTRsCount = stats .Float64 ("running_taskruns_count" ,
90+ "Number of taskruns executing currently" ,
91+ stats .UnitDimensionless )
92+
8193 runningTRs = stats .Float64 ("running_taskruns" ,
8294 "Number of taskruns executing currently" ,
8395 stats .UnitDimensionless )
8496
97+ runningTRsThrottledByQuotaCount = stats .Float64 ("running_taskruns_throttled_by_quota_count" ,
98+ "Number of taskruns executing currently, but whose underlying Pods or Containers are suspended by k8s because of defined ResourceQuotas. Such suspensions can occur as part of initial scheduling of the Pod, or scheduling of any of the subsequent Container(s) in the Pod after the first Container is started" ,
99+ stats .UnitDimensionless )
100+
101+ runningTRsThrottledByNodeCount = stats .Float64 ("running_taskruns_throttled_by_node_count" ,
102+ "Number of taskruns executing currently, but whose underlying Pods or Containers are suspended by k8s because of Node level constraints. Such suspensions can occur as part of initial scheduling of the Pod, or scheduling of any of the subsequent Container(s) in the Pod after the first Container is started" ,
103+ stats .UnitDimensionless )
104+
85105 runningTRsWaitingOnTaskResolutionCount = stats .Float64 ("running_taskruns_waiting_on_task_resolution_count" ,
86106 "Number of taskruns executing currently that are waiting on resolution requests for their task references." ,
87107 stats .UnitDimensionless )
@@ -197,7 +217,9 @@ func viewRegister(cfg *config.Metrics) error {
197217 }
198218 }
199219
220+ trCountViewTags := []tag.Key {statusTag }
200221 if cfg .CountWithReason {
222+ trCountViewTags = append (trCountViewTags , reasonTag )
201223 trunTag = append (trunTag , reasonTag )
202224 }
203225
@@ -214,18 +236,39 @@ func viewRegister(cfg *config.Metrics) error {
214236 TagKeys : append ([]tag.Key {statusTag , namespaceTag }, append (trunTag , prunTag ... )... ),
215237 }
216238
239+ trCountView = & view.View {
240+ Description : trCount .Description (),
241+ Measure : trCount ,
242+ Aggregation : view .Count (),
243+ TagKeys : trCountViewTags ,
244+ }
217245 trTotalView = & view.View {
218246 Description : trTotal .Description (),
219247 Measure : trTotal ,
220248 Aggregation : view .Count (),
221249 TagKeys : []tag.Key {statusTag },
222250 }
251+ runningTRsCountView = & view.View {
252+ Description : runningTRsCount .Description (),
253+ Measure : runningTRsCount ,
254+ Aggregation : view .LastValue (),
255+ }
223256
224257 runningTRsView = & view.View {
225258 Description : runningTRs .Description (),
226259 Measure : runningTRs ,
227260 Aggregation : view .LastValue (),
228261 }
262+ runningTRsThrottledByQuotaCountView = & view.View {
263+ Description : runningTRsThrottledByQuotaCount .Description (),
264+ Measure : runningTRsThrottledByQuotaCount ,
265+ Aggregation : view .LastValue (),
266+ }
267+ runningTRsThrottledByNodeCountView = & view.View {
268+ Description : runningTRsThrottledByNodeCount .Description (),
269+ Measure : runningTRsThrottledByNodeCount ,
270+ Aggregation : view .LastValue (),
271+ }
229272 runningTRsWaitingOnTaskResolutionCountView = & view.View {
230273 Description : runningTRsWaitingOnTaskResolutionCount .Description (),
231274 Measure : runningTRsWaitingOnTaskResolutionCount ,
@@ -257,8 +300,12 @@ func viewRegister(cfg *config.Metrics) error {
257300 return view .Register (
258301 trDurationView ,
259302 prTRDurationView ,
303+ trCountView ,
260304 trTotalView ,
305+ runningTRsCountView ,
261306 runningTRsView ,
307+ runningTRsThrottledByQuotaCountView ,
308+ runningTRsThrottledByNodeCountView ,
262309 runningTRsWaitingOnTaskResolutionCountView ,
263310 runningTRsThrottledByQuotaView ,
264311 runningTRsThrottledByNodeView ,
@@ -270,8 +317,12 @@ func viewUnregister() {
270317 view .Unregister (
271318 trDurationView ,
272319 prTRDurationView ,
320+ trCountView ,
273321 trTotalView ,
322+ runningTRsCountView ,
274323 runningTRsView ,
324+ runningTRsThrottledByQuotaCountView ,
325+ runningTRsThrottledByNodeCountView ,
275326 runningTRsWaitingOnTaskResolutionCountView ,
276327 runningTRsThrottledByQuotaView ,
277328 runningTRsThrottledByNodeView ,
@@ -416,6 +467,7 @@ func (r *Recorder) DurationAndCount(ctx context.Context, tr *v1.TaskRun, beforeC
416467 }
417468
418469 metrics .Record (ctx , durationStat .M (duration .Seconds ()))
470+ metrics .Record (ctx , trCount .M (1 ))
419471 metrics .Record (ctx , trTotal .M (1 ))
420472
421473 return nil
@@ -440,7 +492,9 @@ func (r *Recorder) RunningTaskRuns(ctx context.Context, lister listers.TaskRunLi
440492
441493 var runningTrs int
442494 trsThrottledByQuota := map [string ]int {}
495+ trsThrottledByQuotaCount := 0
443496 trsThrottledByNode := map [string ]int {}
497+ trsThrottledByNodeCount := 0
444498 var trsWaitResolvingTaskRef int
445499 for _ , pr := range trs {
446500 // initialize metrics with namespace tag to zero if unset; will then update as needed below
@@ -462,10 +516,12 @@ func (r *Recorder) RunningTaskRuns(ctx context.Context, lister listers.TaskRunLi
462516 if succeedCondition != nil && succeedCondition .Status == corev1 .ConditionUnknown {
463517 switch succeedCondition .Reason {
464518 case pod .ReasonExceededResourceQuota :
519+ trsThrottledByQuotaCount ++
465520 cnt := trsThrottledByQuota [pr .Namespace ]
466521 cnt ++
467522 trsThrottledByQuota [pr .Namespace ] = cnt
468523 case pod .ReasonExceededNodeResources :
524+ trsThrottledByNodeCount ++
469525 cnt := trsThrottledByNode [pr .Namespace ]
470526 cnt ++
471527 trsThrottledByNode [pr .Namespace ] = cnt
@@ -479,8 +535,11 @@ func (r *Recorder) RunningTaskRuns(ctx context.Context, lister listers.TaskRunLi
479535 if err != nil {
480536 return err
481537 }
538+ metrics .Record (ctx , runningTRsCount .M (float64 (runningTrs )))
482539 metrics .Record (ctx , runningTRs .M (float64 (runningTrs )))
483540 metrics .Record (ctx , runningTRsWaitingOnTaskResolutionCount .M (float64 (trsWaitResolvingTaskRef )))
541+ metrics .Record (ctx , runningTRsThrottledByQuotaCount .M (float64 (trsThrottledByQuotaCount )))
542+ metrics .Record (ctx , runningTRsThrottledByNodeCount .M (float64 (trsThrottledByNodeCount )))
484543
485544 for ns , cnt := range trsThrottledByQuota {
486545 var mutators []tag.Mutator
0 commit comments