|
| 1 | +<!-- |
| 2 | +--- |
| 3 | +linkTitle: "OpenTelemetry Migration" |
| 4 | +weight: 1201 |
| 5 | +--- |
| 6 | +--> |
| 7 | +# Migration Guide: OpenCensus to OpenTelemetry |
| 8 | + |
| 9 | +This guide covers changes for cluster operators upgrading Tekton Triggers |
| 10 | +to a version that uses OpenTelemetry for metrics and tracing. The Triggers |
| 11 | +API (EventListener, TriggerTemplate, TriggerBinding, etc.) is unchanged. |
| 12 | + |
| 13 | +This migration aligns Triggers with |
| 14 | +[Tekton Pipeline PR #9043](https://github.com/tektoncd/pipeline/pull/9043) |
| 15 | +and Knative's migration from `knative.dev/pkg/metrics` (OpenCensus) to |
| 16 | +`knative.dev/pkg/observability` (OpenTelemetry). |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## What changed |
| 21 | + |
| 22 | +| Area | Before | After | |
| 23 | +|---|---|---| |
| 24 | +| Metrics library | OpenCensus (`go.opencensus.io`) | OpenTelemetry (`go.opentelemetry.io/otel`) | |
| 25 | +| ConfigMap key for metrics | `metrics.backend-destination` | `metrics-protocol` | |
| 26 | +| ConfigMap key for tracing | Separate `config-tracing` / `K_TRACING_CONFIG` | Unified in `config-observability-triggers` (`tracing-protocol`) | |
| 27 | +| Stackdriver support | Built-in | Use OTLP with a GCP exporter | |
| 28 | +| Counter metric names | `event_received_count` | `event_received_count_total` | |
| 29 | +| Counter metric names | `triggered_resources` | `triggered_resources_total` | |
| 30 | +| Default metrics export | Prometheus on port 9000 | Prometheus on port 9000 (unchanged) | |
| 31 | +| Metrics port | 9000 | 9000 (unchanged) | |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +## Step 1: Observability ConfigMap |
| 36 | + |
| 37 | +The `config-observability-triggers` ConfigMap ships with |
| 38 | +`metrics-protocol: prometheus` as active data, so Prometheus metrics |
| 39 | +remain enabled by default. |
| 40 | + |
| 41 | +The `_example` block now documents the new OpenTelemetry configuration |
| 42 | +keys. The old OpenCensus keys (`metrics.backend-destination`, |
| 43 | +`metrics.stackdriver-project-id`, `metrics.allow-stackdriver-custom-metrics`) |
| 44 | +are no longer recognized. |
| 45 | + |
| 46 | +**If you had no custom observability configuration**, no action is needed. |
| 47 | + |
| 48 | +**If you had custom values**, translate them: |
| 49 | + |
| 50 | +| Old key | New key | |
| 51 | +|---|---| |
| 52 | +| `metrics.backend-destination: prometheus` | `metrics-protocol: prometheus` | |
| 53 | +| `metrics.backend-destination: opencensus` | `metrics-protocol: grpc` + `metrics-endpoint: <host:port>` | |
| 54 | +| `metrics.backend-destination: none` | `metrics-protocol: none` | |
| 55 | +| `metrics.opencensus-address` | `metrics-endpoint` | |
| 56 | +| `metrics.reporting-period-seconds: 60` | `metrics-export-interval: 60s` | |
| 57 | + |
| 58 | +After changing the ConfigMap, restart the controller: |
| 59 | + |
| 60 | +```bash |
| 61 | +kubectl -n tekton-pipelines rollout restart deployment tekton-triggers-controller |
| 62 | +``` |
| 63 | + |
| 64 | +--- |
| 65 | + |
| 66 | +## Step 2: Update Prometheus queries |
| 67 | + |
| 68 | +Counter metrics now have a `_total` suffix per Prometheus naming conventions: |
| 69 | + |
| 70 | +```promql |
| 71 | +# Before |
| 72 | +event_received_count{status="succeeded"} |
| 73 | +triggered_resources{kind="PipelineRun"} |
| 74 | +
|
| 75 | +# After |
| 76 | +event_received_count_total{status="succeeded"} |
| 77 | +triggered_resources_total{kind="PipelineRun"} |
| 78 | +``` |
| 79 | + |
| 80 | +Gauge and histogram queries are unchanged: |
| 81 | + |
| 82 | +```promql |
| 83 | +# These work as before |
| 84 | +eventlistener_count |
| 85 | +clusterinterceptor_count |
| 86 | +http_duration_seconds_bucket{le="5.0"} |
| 87 | +``` |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +## Step 3: Account for new OTel scope labels |
| 92 | + |
| 93 | +All metrics now include OpenTelemetry instrumentation scope labels: |
| 94 | + |
| 95 | +- `otel_scope_name` (e.g. `github.com/tektoncd/triggers/pkg/sink` |
| 96 | + for sink metrics, `github.com/tektoncd/triggers/pkg/reconciler/metrics` |
| 97 | + for controller gauge metrics) |
| 98 | +- `otel_scope_schema_url` (emitted but empty) |
| 99 | +- `otel_scope_version` (emitted but empty) |
| 100 | + |
| 101 | +Only `otel_scope_name` carries a meaningful value. These labels are |
| 102 | +informational and transparent to most PromQL queries. If you use strict |
| 103 | +label matching in recording rules or alerts, account for the new |
| 104 | +`otel_scope_name` label. |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## Step 4: Verify |
| 109 | + |
| 110 | +```bash |
| 111 | +kubectl -n tekton-pipelines port-forward svc/tekton-triggers-controller 9000:9000 |
| 112 | +curl -s http://localhost:9000/metrics | grep -E "eventlistener_count|event_received_count_total" |
| 113 | +``` |
| 114 | + |
| 115 | +--- |
| 116 | + |
| 117 | +## No action required |
| 118 | + |
| 119 | +- **Triggers API**: All CRDs are unchanged. |
| 120 | +- **Metrics port**: Still 9000, controlled by `METRICS_PROMETHEUS_PORT`. |
| 121 | +- **Metric semantics**: All metrics measure the same things with the same |
| 122 | + labels (`status`, `kind`). |
| 123 | +- **EventListener behavior**: Events are processed identically. |
| 124 | + |
| 125 | +--- |
| 126 | + |
| 127 | +## Rollback |
| 128 | + |
| 129 | +Redeploy the previous Triggers release. The old OpenCensus keys will work |
| 130 | +again. No data migration is needed. |
0 commit comments