Skip to content

Commit 85c3c24

Browse files
committed
feat: Migrate PipelineRun and TaskRun metrics to OpenTelemetry
This commit migrates the metrics for PipelineRuns and TaskRuns from OpenCensus to OpenTelemetry. The following changes are included: - Updated the observability config to support OpenTelemetry. - Migrated the implementation of PipelineRun and TaskRun metrics to use the OpenTelemetry Go SDK. - Updated the tests to work with the new OpenTelemetry-based implementation.
1 parent a3e3e39 commit 85c3c24

File tree

8 files changed

+1673
-1703
lines changed

8 files changed

+1673
-1703
lines changed

config/config-observability.yaml

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ metadata:
2121
app.kubernetes.io/instance: default
2222
app.kubernetes.io/part-of: tekton-pipelines
2323
data:
24+
metrics-protocol: prometheus
2425
_example: |
2526
################################
2627
# #
@@ -37,23 +38,46 @@ data:
3738
# this example block and unindented to be in the data block
3839
# to actually change the configuration.
3940
40-
# metrics.backend-destination field specifies the system metrics destination.
41-
# It supports either prometheus (the default) or stackdriver.
42-
# Note: Using Stackdriver will incur additional charges.
43-
metrics.backend-destination: prometheus
44-
45-
# metrics.stackdriver-project-id field specifies the Stackdriver project ID. This
46-
# field is optional. When running on GCE, application default credentials will be
47-
# used and metrics will be sent to the cluster's project if this field is
48-
# not provided.
49-
metrics.stackdriver-project-id: "<your stackdriver project id>"
50-
51-
# metrics.allow-stackdriver-custom-metrics indicates whether it is allowed
52-
# to send metrics to Stackdriver using "global" resource type and custom
53-
# metric type. Setting this flag to "true" could cause extra Stackdriver
54-
# charge. If metrics.backend-destination is not Stackdriver, this is
55-
# ignored.
56-
metrics.allow-stackdriver-custom-metrics: "false"
41+
# OpenTelemetry Metrics Configuration
42+
# Protocol for metrics export (prometheus, grpc, http/protobuf, none)
43+
# Default if not specified: "none"
44+
metrics-protocol: prometheus
45+
46+
# Metrics endpoint (for grpc/http protocols)
47+
# Default: empty (uses default OTLP endpoint)
48+
metrics-endpoint: ""
49+
50+
# Metrics export interval (e.g., "30s", "1m")
51+
# Default: empty (uses default interval)
52+
metrics-export-interval: ""
53+
54+
# OpenTelemetry Tracing Configuration
55+
# Protocol for tracing export (grpc, http/protobuf, none, stdout)
56+
# Default: none
57+
tracing-protocol: none
58+
59+
# Tracing endpoint (for grpc/http protocols)
60+
# Default: empty
61+
tracing-endpoint: ""
62+
63+
# Tracing sampling rate (0.0 to 1.0)
64+
# Default: 1.0 (100% sampling)
65+
tracing-sampling-rate: "1.0"
66+
67+
# Runtime Configuration
68+
# Enable profiling (enabled, disabled)
69+
# Default: disabled
70+
runtime-profiling: disabled
71+
72+
# Runtime export interval (e.g., "15s")
73+
# Default: 15s
74+
runtime-export-interval: "15s"
75+
76+
# Note: Legacy OpenCensus configuration (metrics.backend-destination, etc.) has been
77+
# removed as OpenCensus support is no longer provided by the underlying infrastructure.
78+
# Please use the OpenTelemetry configuration options above.
79+
80+
# Tekton-specific metrics configuration
5781
metrics.taskrun.level: "task"
5882
metrics.taskrun.duration-type: "histogram"
5983
metrics.pipelinerun.level: "pipeline"
Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 The Tekton Authors
1+
# Copyright 2019 The Tekton Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -16,13 +16,12 @@ apiVersion: v1
1616
kind: ConfigMap
1717
metadata:
1818
name: config-observability
19-
namespace: tekton-pipelines-resolvers
19+
namespace: tekton-pipelines
2020
labels:
21-
app.kubernetes.io/component: resolvers
2221
app.kubernetes.io/instance: default
2322
app.kubernetes.io/part-of: tekton-pipelines
24-
2523
data:
24+
metrics-protocol: prometheus
2625
_example: |
2726
################################
2827
# #
@@ -39,24 +38,41 @@ data:
3938
# this example block and unindented to be in the data block
4039
# to actually change the configuration.
4140
42-
# metrics.backend-destination field specifies the system metrics destination.
43-
# It supports either prometheus (the default) or stackdriver.
44-
# Note: Using stackdriver will incur additional charges
45-
metrics.backend-destination: prometheus
46-
47-
# metrics.request-metrics-backend-destination specifies the request metrics
48-
# destination. If non-empty, it enables queue proxy to send request metrics.
49-
# Currently supported values: prometheus, stackdriver.
50-
metrics.request-metrics-backend-destination: prometheus
51-
52-
# metrics.stackdriver-project-id field specifies the stackdriver project ID. This
53-
# field is optional. When running on GCE, application default credentials will be
54-
# used if this field is not provided.
55-
metrics.stackdriver-project-id: "<your stackdriver project id>"
56-
57-
# metrics.allow-stackdriver-custom-metrics indicates whether it is allowed to send metrics to
58-
# Stackdriver using "global" resource type and custom metric type if the
59-
# metrics are not supported by "knative_revision" resource type. Setting this
60-
# flag to "true" could cause extra Stackdriver charge.
61-
# If metrics.backend-destination is not Stackdriver, this is ignored.
62-
metrics.allow-stackdriver-custom-metrics: "false"
41+
# OpenTelemetry Metrics Configuration
42+
# Protocol for metrics export (prometheus, grpc, http/protobuf, none)
43+
# Default if not specified: "none"
44+
metrics-protocol: prometheus
45+
46+
# Metrics endpoint (for grpc/http protocols)
47+
# Default: empty (uses default OTLP endpoint)
48+
metrics-endpoint: ""
49+
50+
# Metrics export interval (e.g., "30s", "1m")
51+
# Default: empty (uses default interval)
52+
metrics-export-interval: ""
53+
54+
# OpenTelemetry Tracing Configuration
55+
# Protocol for tracing export (grpc, http/protobuf, none, stdout)
56+
# Default: none
57+
tracing-protocol: none
58+
59+
# Tracing endpoint (for grpc/http protocols)
60+
# Default: empty
61+
tracing-endpoint: ""
62+
63+
# Tracing sampling rate (0.0 to 1.0)
64+
# Default: 1.0 (100% sampling)
65+
tracing-sampling-rate: "1.0"
66+
67+
# Runtime Configuration
68+
# Enable profiling (enabled, disabled)
69+
# Default: disabled
70+
runtime-profiling: disabled
71+
72+
# Runtime export interval (e.g., "15s")
73+
# Default: 15s
74+
runtime-export-interval: "15s"
75+
76+
# Note: Legacy OpenCensus configuration (metrics.backend-destination, etc.) has been
77+
# removed as OpenCensus support is no longer provided by the underlying infrastructure.
78+
# Please use the OpenTelemetry configuration options above.

pkg/apis/config/metrics.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,11 @@ func (cfg *Metrics) Equals(other *Metrics) bool {
120120

121121
return other.TaskrunLevel == cfg.TaskrunLevel &&
122122
other.PipelinerunLevel == cfg.PipelinerunLevel &&
123+
other.RunningPipelinerunLevel == cfg.RunningPipelinerunLevel &&
123124
other.DurationTaskrunType == cfg.DurationTaskrunType &&
124125
other.DurationPipelinerunType == cfg.DurationPipelinerunType &&
125-
other.CountWithReason == cfg.CountWithReason
126+
other.CountWithReason == cfg.CountWithReason &&
127+
other.ThrottleWithNamespace == cfg.ThrottleWithNamespace
126128
}
127129

128130
// newMetricsFromMap returns a Config given a map corresponding to a ConfigMap

0 commit comments

Comments
 (0)