diff --git a/docs/metrics.md b/docs/metrics.md
index dae43467221..68441559ead 100644
--- a/docs/metrics.md
+++ b/docs/metrics.md
@@ -14,13 +14,13 @@ We expose several kinds of exporters, including Prometheus, Google Stackdriver,
| Name | Type | Labels/Tags | Status |
|-----------------------------------------------------------------------------------------| ----------- |-------------------------------------------------| ----------- |
| `tekton_pipelines_controller_pipelinerun_duration_seconds_[bucket, sum, count]` | Histogram/LastValue(Gauge) | `*pipeline`=<pipeline_name>
`*pipelinerun`=<pipelinerun_name>
`status`=<status>
`namespace`=<pipelinerun-namespace> | experimental |
-| `tekton_pipelines_controller_pipelinerun_taskrun_duration_seconds_[bucket, sum, count]` | Histogram/LastValue(Gauge) | `*pipeline`=<pipeline_name>
`*pipelinerun`=<pipelinerun_name>
`status`=<status>
`*task`=<task_name>
`*taskrun`=<taskrun_name>
`namespace`=<pipelineruns-taskruns-namespace> | experimental |
-| `tekton_pipelines_controller_pipelinerun_count` | Counter | `status`=<status> | deprecate |
+| `tekton_pipelines_controller_pipelinerun_taskrun_duration_seconds_[bucket, sum, count]` | Histogram/LastValue(Gauge) | `*pipeline`=<pipeline_name>
`*pipelinerun`=<pipelinerun_name>
`status`=<status>
`*task`=<task_name>
`*taskrun`=<taskrun_name>
`namespace`=<pipelineruns-taskruns-namespace>
`*reason`=<reason> | experimental |
+| `tekton_pipelines_controller_pipelinerun_count` | Counter | `status`=<status>
`*reason`=<reason> | deprecate |
| `tekton_pipelines_controller_pipelinerun_total` | Counter | `status`=<status> | experimental |
| `tekton_pipelines_controller_running_pipelineruns_count` | Gauge | | deprecate |
| `tekton_pipelines_controller_running_pipelineruns` | Gauge | | experimental |
-| `tekton_pipelines_controller_taskrun_duration_seconds_[bucket, sum, count]` | Histogram/LastValue(Gauge) | `status`=<status>
`*task`=<task_name>
`*taskrun`=<taskrun_name>
`namespace`=<pipelineruns-taskruns-namespace> | experimental |
-| `tekton_pipelines_controller_taskrun_count` | Counter | `status`=<status> | deprecate |
+| `tekton_pipelines_controller_taskrun_duration_seconds_[bucket, sum, count]` | Histogram/LastValue(Gauge) | `status`=<status>
`*task`=<task_name>
`*taskrun`=<taskrun_name>
`namespace`=<pipelineruns-taskruns-namespace>
`*reason`=<reason> | experimental |
+| `tekton_pipelines_controller_taskrun_count` | Counter | `status`=<status>
`*reason`=<reason> | deprecate |
| `tekton_pipelines_controller_taskrun_total` | Counter | `status`=<status> | experimental |
| `tekton_pipelines_controller_running_taskruns_count` | Gauge | | deprecate |
| `tekton_pipelines_controller_running_taskruns` | Gauge | | experimental |
diff --git a/pkg/pipelinerunmetrics/metrics.go b/pkg/pipelinerunmetrics/metrics.go
index b389cf4907b..c89428bd67f 100644
--- a/pkg/pipelinerunmetrics/metrics.go
+++ b/pkg/pipelinerunmetrics/metrics.go
@@ -174,6 +174,12 @@ func viewRegister(cfg *config.Metrics) error {
}
}
+ prCountViewTags := []tag.Key{statusTag}
+ if cfg.CountWithReason {
+ prCountViewTags = append(prCountViewTags, reasonTag)
+ prunTag = append(prunTag, reasonTag)
+ }
+
prDurationView = &view.View{
Description: prDuration.Description(),
Measure: prDuration,
@@ -181,10 +187,6 @@ func viewRegister(cfg *config.Metrics) error {
TagKeys: append([]tag.Key{statusTag, namespaceTag}, prunTag...),
}
- prCountViewTags := []tag.Key{statusTag}
- if cfg.CountWithReason {
- prCountViewTags = append(prCountViewTags, reasonTag)
- }
prCountView = &view.View{
Description: prCount.Description(),
Measure: prCount,
diff --git a/pkg/pipelinerunmetrics/metrics_test.go b/pkg/pipelinerunmetrics/metrics_test.go
index 5a7c757e512..0633335008a 100644
--- a/pkg/pipelinerunmetrics/metrics_test.go
+++ b/pkg/pipelinerunmetrics/metrics_test.go
@@ -339,6 +339,7 @@ func TestRecordPipelineRunDurationCount(t *testing.T) {
"pipeline": "pipeline-1",
"pipelinerun": "pipelinerun-1",
"namespace": "ns",
+ "reason": "Failed",
"status": "failed",
},
expectedCountTags: map[string]string{
@@ -375,6 +376,7 @@ func TestRecordPipelineRunDurationCount(t *testing.T) {
"pipelinerun": "pipelinerun-1",
"namespace": "ns",
"status": "cancelled",
+ "reason": ReasonCancelled.String(),
},
expectedCountTags: map[string]string{
"status": "cancelled",
diff --git a/pkg/taskrunmetrics/metrics.go b/pkg/taskrunmetrics/metrics.go
index c50dc4e6788..050398b24a6 100644
--- a/pkg/taskrunmetrics/metrics.go
+++ b/pkg/taskrunmetrics/metrics.go
@@ -212,6 +212,12 @@ func viewRegister(cfg *config.Metrics) error {
}
}
+ trCountViewTags := []tag.Key{statusTag}
+ if cfg.CountWithReason {
+ trCountViewTags = append(trCountViewTags, reasonTag)
+ trunTag = append(trunTag, reasonTag)
+ }
+
trDurationView = &view.View{
Description: trDuration.Description(),
Measure: trDuration,
@@ -225,10 +231,6 @@ func viewRegister(cfg *config.Metrics) error {
TagKeys: append([]tag.Key{statusTag, namespaceTag}, append(trunTag, prunTag...)...),
}
- trCountViewTags := []tag.Key{statusTag}
- if cfg.CountWithReason {
- trCountViewTags = append(trCountViewTags, reasonTag)
- }
trCountView = &view.View{
Description: trCount.Description(),
Measure: trCount,
diff --git a/pkg/taskrunmetrics/metrics_test.go b/pkg/taskrunmetrics/metrics_test.go
index e9ce6743e8d..e58a2dcb849 100644
--- a/pkg/taskrunmetrics/metrics_test.go
+++ b/pkg/taskrunmetrics/metrics_test.go
@@ -391,6 +391,7 @@ func TestRecordTaskRunDurationCount(t *testing.T) {
"task": "task-1",
"taskrun": "taskrun-1",
"namespace": "ns",
+ "reason": "TaskRunImagePullFailed",
"status": "failed",
},
expectedCountTags: map[string]string{