Skip to content

Commit baaf5e1

Browse files
committed
refactor: migrate from OpenCensus to OpenTelemetry
Replace OpenCensus stats, views, and tags with OpenTelemetry meter, counters, and attributes for all pipeline run metrics. Update method signatures to accept context.Context and rewrite tests to use the OTel SDK ManualReader. Remove the now-unnecessary metricstest helper package and all OpenCensus vendor dependencies. Signed-off-by: Zaki Shaikh <zashaikh@redhat.com>
1 parent de28dca commit baaf5e1

File tree

904 files changed

+102473
-91368
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

904 files changed

+102473
-91368
lines changed

cmd/pipelines-as-code-controller/main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ func main() {
3838

3939
loggerConfiguratorOpt := evadapter.WithLoggerConfiguratorConfigMapName(logging.ConfigMapName())
4040
loggerConfigurator := evadapter.NewLoggerConfiguratorFromConfigMap(PACControllerLogKey, loggerConfiguratorOpt)
41-
copt := evadapter.WithLoggerConfigurator(loggerConfigurator)
41+
copts := []evadapter.ConfiguratorOption{
42+
evadapter.WithLoggerConfigurator(loggerConfigurator),
43+
evadapter.WithObservabilityConfigurator(evadapter.NewObservabilityConfiguratorFromConfigMap()),
44+
evadapter.WithCloudEventsStatusReporterConfigurator(evadapter.NewCloudEventsReporterConfiguratorFromConfigMap()),
45+
}
4246
// put logger configurator to ctx
43-
ctx = evadapter.WithConfiguratorOptions(ctx, []evadapter.ConfiguratorOption{copt})
47+
ctx = evadapter.WithConfiguratorOptions(ctx, copts)
4448

4549
ctx = info.StoreNS(ctx, system.Namespace())
4650
ctx = info.StoreCurrentControllerName(ctx, run.Info.Controller.Name)

config/305-config-observability.yaml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ metadata:
2121
app.kubernetes.io/version: "devel"
2222
app.kubernetes.io/part-of: pipelines-as-code
2323
data:
24+
metrics-protocol: prometheus
25+
metrics-endpoint: ":9090"
2426
_example: |
2527
################################
2628
# #
@@ -35,18 +37,17 @@ data:
3537
# These sample configuration options may be copied out of
3638
# this example block and unindented to be in the data block
3739
# to actually change the configuration.
38-
# metrics.backend-destination field specifies the system metrics destination.
39-
# It supports either prometheus (the default) or stackdriver.
40-
# Note: Using Stackdriver will incur additional charges.
41-
metrics.backend-destination: prometheus
42-
# metrics.stackdriver-project-id field specifies the Stackdriver project ID. This
43-
# field is optional. When running on GCE, application default credentials will be
44-
# used and metrics will be sent to the cluster's project if this field is
45-
# not provided.
46-
metrics.stackdriver-project-id: "<your stackdriver project id>"
47-
# metrics.allow-stackdriver-custom-metrics indicates whether it is allowed
48-
# to send metrics to Stackdriver using "global" resource type and custom
49-
# metric type. Setting this flag to "true" could cause extra Stackdriver
50-
# charge. If metrics.backend-destination is not Stackdriver, this is
51-
# ignored.
52-
metrics.allow-stackdriver-custom-metrics: "false"
40+
41+
# metrics-protocol specifies the metrics export protocol.
42+
# Supported values: "prometheus", "grpc", "http/protobuf", "none".
43+
# Default is "none" (metrics disabled).
44+
metrics-protocol: prometheus
45+
46+
# metrics-endpoint specifies the host:port for the metrics server.
47+
# For prometheus, this is the listen address (e.g. ":9090").
48+
# For grpc/http, this is the collector endpoint.
49+
# metrics-endpoint: ""
50+
51+
# metrics-export-interval specifies how often metrics are exported.
52+
# Only applicable for grpc and http/protobuf protocols.
53+
# metrics-export-interval: "30s"

config/400-controller.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,8 @@ spec:
8989
valueFrom:
9090
fieldRef:
9191
fieldPath: metadata.namespace
92-
- name: K_METRICS_CONFIG
93-
value: '{"Domain":"pipelinesascode.tekton.dev/controller","Component":"pac_controller","PrometheusPort":9090,"ConfigMap":{"name":"pipelines-as-code-config-observability"}}'
94-
- name: K_TRACING_CONFIG
95-
value: '{"backend":"prometheus","debug":"false","sample-rate":"0"}'
92+
- name: CONFIG_OBSERVABILITY_NAME
93+
value: pipelines-as-code-config-observability
9694
- name: K_SINK_TIMEOUT
9795
value: "30"
9896
- name: PAC_CONTROLLER_LABEL

go.mod

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/openshift-pipelines/pipelines-as-code
22

3-
go 1.25.0
3+
go 1.25.6
44

55
require (
66
codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v3 v3.0.0
@@ -10,7 +10,7 @@ require (
1010
github.com/cloudevents/sdk-go/v2 v2.16.2
1111
github.com/fvbommel/sortorder v1.1.0
1212
github.com/gobwas/glob v0.2.3
13-
github.com/google/cel-go v0.26.1
13+
github.com/google/cel-go v0.27.0
1414
github.com/google/go-cmp v0.7.0
1515
github.com/google/go-github/scrape v0.0.0-20260114152324-5458fbc09dc5
1616
github.com/google/go-github/v75 v75.0.0
@@ -27,35 +27,42 @@ require (
2727
github.com/pkg/errors v0.9.1
2828
github.com/spf13/cobra v1.10.2
2929
github.com/stretchr/testify v1.11.1
30-
github.com/tektoncd/pipeline v1.7.0
30+
github.com/tektoncd/pipeline v1.10.0
3131
gitlab.com/gitlab-org/api/client-go v1.14.0
32-
go.opencensus.io v0.24.0
32+
go.opentelemetry.io/otel v1.39.0
33+
go.opentelemetry.io/otel/metric v1.39.0
34+
go.opentelemetry.io/otel/sdk/metric v1.39.0
3335
go.uber.org/zap v1.27.1
3436
golang.org/x/exp v0.0.0-20260112195511-716be5621a96
35-
golang.org/x/oauth2 v0.34.0
37+
golang.org/x/oauth2 v0.35.0
3638
golang.org/x/sync v0.19.0
37-
golang.org/x/text v0.33.0
39+
golang.org/x/text v0.34.0
3840
gopkg.in/yaml.v2 v2.4.0
3941
gotest.tools/v3 v3.5.2
4042
k8s.io/api v0.35.0
4143
k8s.io/apimachinery v0.35.0
4244
k8s.io/client-go v0.35.0
4345
k8s.io/utils v0.0.0-20260108192941-914a6e750570
44-
knative.dev/eventing v0.47.0
45-
knative.dev/pkg v0.0.0-20260114161248-8c840449eed2
46+
knative.dev/eventing v0.47.2
47+
knative.dev/pkg v0.0.0-20260120122510-4a022ed9999a
4648
sigs.k8s.io/yaml v1.6.0
4749
)
4850

4951
require (
5052
cel.dev/expr v0.25.1 // indirect
5153
github.com/42wim/httpsig v1.2.3 // indirect
5254
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect
55+
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
5356
github.com/cert-manager/cert-manager v1.19.3 // indirect
57+
github.com/cloudevents/sdk-go/observability/opentelemetry/v2 v2.16.1 // indirect
5458
github.com/cloudevents/sdk-go/sql/v2 v2.16.2 // indirect
5559
github.com/coreos/go-oidc/v3 v3.17.0 // indirect
60+
github.com/felixge/httpsnoop v1.0.4 // indirect
5661
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
5762
github.com/go-jose/go-jose/v3 v3.0.4 // indirect
5863
github.com/go-jose/go-jose/v4 v4.1.3 // indirect
64+
github.com/go-logr/stdr v1.2.2 // indirect
65+
github.com/go-logr/zapr v1.3.0 // indirect
5966
github.com/go-openapi/errors v0.22.6 // indirect
6067
github.com/go-openapi/strfmt v0.25.0 // indirect
6168
github.com/go-openapi/swag/cmdutils v0.25.4 // indirect
@@ -71,10 +78,24 @@ require (
7178
github.com/go-openapi/swag/yamlutils v0.25.4 // indirect
7279
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
7380
github.com/oklog/ulid v1.3.1 // indirect
81+
github.com/prometheus/otlptranslator v1.0.0 // indirect
7482
github.com/rickb777/plural v1.4.7 // indirect
7583
github.com/robfig/cron/v3 v3.0.1 // indirect
7684
github.com/x448/float16 v0.8.4 // indirect
7785
go.mongodb.org/mongo-driver v1.17.7 // indirect
86+
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
87+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0 // indirect
88+
go.opentelemetry.io/contrib/instrumentation/runtime v0.64.0 // indirect
89+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.39.0 // indirect
90+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.39.0 // indirect
91+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0 // indirect
92+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0 // indirect
93+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.39.0 // indirect
94+
go.opentelemetry.io/otel/exporters/prometheus v0.61.0 // indirect
95+
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.39.0 // indirect
96+
go.opentelemetry.io/otel/sdk v1.39.0 // indirect
97+
go.opentelemetry.io/otel/trace v1.39.0 // indirect
98+
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
7899
go.uber.org/atomic v1.11.0 // indirect
79100
go.yaml.in/yaml/v2 v2.4.3 // indirect
80101
go.yaml.in/yaml/v3 v3.0.4 // indirect
@@ -86,18 +107,13 @@ require (
86107
)
87108

88109
require (
89-
contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d // indirect
90-
contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect
91-
contrib.go.opencensus.io/exporter/zipkin v0.1.2 // indirect
92110
github.com/PuerkitoBio/goquery v1.11.0 // indirect
93111
github.com/andybalholm/cascadia v1.3.3 // indirect
94112
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
95113
github.com/beorn7/perks v1.0.1 // indirect
96114
github.com/blang/semver/v4 v4.0.0 // indirect
97115
github.com/blendle/zapdriver v1.3.1 // indirect
98-
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
99116
github.com/cespare/xxhash/v2 v2.3.0 // indirect
100-
github.com/cloudevents/sdk-go/observability/opencensus/v2 v2.16.2 // indirect
101117
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
102118
github.com/davidmz/go-pageant v1.0.2 // indirect
103119
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
@@ -108,8 +124,6 @@ require (
108124
github.com/go-openapi/jsonreference v0.21.4 // indirect
109125
github.com/go-openapi/swag v0.25.4 // indirect
110126
github.com/golang-jwt/jwt/v4 v4.5.2
111-
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
112-
github.com/golang/protobuf v1.5.4 // indirect
113127
github.com/google/gnostic-models v0.7.1 // indirect
114128
github.com/google/go-querystring v1.2.0 // indirect
115129
github.com/google/uuid v1.6.0 // indirect
@@ -126,28 +140,24 @@ require (
126140
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
127141
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
128142
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
129-
github.com/openzipkin/zipkin-go v0.4.3 // indirect
130143
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
131144
github.com/prometheus/client_golang v1.23.2 // indirect
132145
github.com/prometheus/client_model v0.6.2 // indirect
133146
github.com/prometheus/common v0.67.5 // indirect
134147
github.com/prometheus/procfs v0.19.2 // indirect
135-
github.com/prometheus/statsd_exporter v0.28.0 // indirect
136148
github.com/rickb777/date v1.22.0 // indirect
137149
github.com/spf13/pflag v1.0.10 // indirect
138-
github.com/stoewer/go-strcase v1.3.1 // indirect
139150
github.com/xlzd/gotp v0.1.0 // indirect
140151
go.uber.org/automaxprocs v1.6.0 // indirect
141152
go.uber.org/multierr v1.11.0 // indirect
142-
golang.org/x/crypto v0.47.0 // indirect
143-
golang.org/x/net v0.49.0 // indirect
144-
golang.org/x/sys v0.40.0 // indirect
145-
golang.org/x/term v0.39.0
153+
golang.org/x/crypto v0.48.0 // indirect
154+
golang.org/x/net v0.50.0 // indirect
155+
golang.org/x/sys v0.41.0 // indirect
156+
golang.org/x/term v0.40.0
146157
golang.org/x/time v0.14.0 // indirect
147158
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
148-
google.golang.org/api v0.260.0 // indirect
149-
google.golang.org/genproto/googleapis/api v0.0.0-20260114163908-3f89685c29c3
150-
google.golang.org/genproto/googleapis/rpc v0.0.0-20260114163908-3f89685c29c3 // indirect
159+
google.golang.org/genproto/googleapis/api v0.0.0-20260128011058-8636f8732409
160+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 // indirect
151161
google.golang.org/grpc v1.79.3 // indirect
152162
google.golang.org/protobuf v1.36.11
153163
gopkg.in/inf.v0 v0.9.1 // indirect
@@ -156,8 +166,3 @@ require (
156166
k8s.io/klog/v2 v2.130.1
157167
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
158168
)
159-
160-
replace (
161-
knative.dev/eventing => knative.dev/eventing v0.45.0
162-
knative.dev/pkg => knative.dev/pkg v0.0.0-20250424013628-d5e74d29daa3
163-
)

0 commit comments

Comments
 (0)