Skip to content

feat(metrics): Migration from OpenCensus to OpenTelemetry#1934

Merged
tekton-robot merged 4 commits intotektoncd:mainfrom
infernus01:migration-otel
Mar 31, 2026
Merged

feat(metrics): Migration from OpenCensus to OpenTelemetry#1934
tekton-robot merged 4 commits intotektoncd:mainfrom
infernus01:migration-otel

Conversation

@infernus01
Copy link
Copy Markdown
Member

@infernus01 infernus01 commented Dec 15, 2025

Changes

Migrates Triggers metrics implementation from the deprecated OpenCensus library to OpenTelemetry, aligning with Knative's observability stack modernization.

Changes include:

  • Replace OpenCensus imports (go.opencensus.io/stats, stats/view, tag) with OpenTelemetry (go.opentelemetry.io/otel, otel/attribute, otel/metric) in pkg/sink/metrics.go and pkg/reconciler/metrics/metrics.go
  • Convert elDuration to metric.Float64Histogram, eventRcdCount and triggeredResources to metric.Int64Counter
  • Convert reconciler gauge metrics (eventlistener_count, triggerbinding_count, clustertriggerbinding_count,
    triggertemplate_count, clusterinterceptor_count) to metric.Float64Gauge
  • Update knative.dev/pkg to v0.0.0-20260120122510-4a022ed9999a (includes new observability package)
  • Update knative.dev/eventing to v0.0.0-20260209140146-9e76da08faaa (compatible with new knative.dev/pkg without deprecated metrics package)
  • Update tektoncd/pipeline to v1.10.0 (OpenTelemetry migrated)
  • Update test expectations for new observability config format (K_OBSERVABILITY_CONFIG replacing K_METRICS_CONFIG and K_TRACING_CONFIG)
  • Simplify metrics tests to work without deprecated knative.dev/pkg/metrics/metricstest

All existing metrics continue to be exported with the same names and semantics. Counter metrics gain a _total suffix per Prometheus naming conventions when using the OTel Prometheus exporter.

fixes : #1964
/kind feature

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

Migrated metrics from OpenCensus to OpenTelemetry.

  ACTION REQUIRED:

  1. Configuration key change
     Replace metrics.backend-destination with metrics-protocol in your config-observability-triggers ConfigMap.
     Prometheus export remains the default — no change needed if you were not customizing observability.

  2. Infrastructure metric renaming
     Infrastructure metrics (workqueue, K8s client) have been renamed from the
     tekton_triggers_controller_ prefix to standard Knative/OpenTelemetry namespaces.

     ┌──────────────────────────────────────────────────────────┬───────────────────────────────────────────────────┐
     │ Old Metric Name (OpenCensus)                             │ New Metric Name (OpenTelemetry)                   │
     ├──────────────────────────────────────────────────────────┼───────────────────────────────────────────────────┤
     │ tekton_triggers_controller_workqueue_depth               │ kn_workqueue_depth                                │
     │ tekton_triggers_controller_workqueue_adds_total          │ kn_workqueue_adds_total                           │
     │ tekton_triggers_controller_workqueue_queue_latency_*     │ kn_workqueue_queue_duration_seconds_*             │
     │ tekton_triggers_controller_workqueue_work_duration_*     │ kn_workqueue_process_duration_seconds_*           │
     │ tekton_triggers_controller_workqueue_unfinished_work_*   │ kn_workqueue_unfinished_work_seconds              │
     │ tekton_triggers_controller_workqueue_retries_total       │ kn_workqueue_retries_total                        │
     │ tekton_triggers_controller_client_latency               │ http_client_request_duration_seconds_*            │
     │ tekton_triggers_controller_client_results               │ kn_k8s_client_http_response_status_code_total     │
     └──────────────────────────────────────────────────────────┴───────────────────────────────────────────────────┘

  3. Sink counter metrics renamed

     ┌──────────────────────────────────────────┬────────────────────────────────────────────┐
     │ Old Metric Name (OpenCensus)             │ New Metric Name (OpenTelemetry)            │
     ├──────────────────────────────────────────┼────────────────────────────────────────────┤
     │ eventlistener_event_received_count       │ eventlistener_event_received_total         │
     │ eventlistener_triggered_resources        │ eventlistener_triggered_resources_total    │
     └──────────────────────────────────────────┴────────────────────────────────────────────┘

  4. All other metric names are unchanged
     controller_eventlistener_count, controller_triggerbinding_count,
     controller_triggertemplate_count, controller_clustertriggerbinding_count,
     controller_clusterinterceptor_count, eventlistener_http_duration_seconds

@tekton-robot tekton-robot added release-note-none Denotes a PR that doesnt merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Dec 15, 2025
@tekton-robot tekton-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Dec 15, 2025
@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 19, 2026
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 21, 2026
Copy link
Copy Markdown
Contributor

@khrm khrm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you first run hack/update-codegen.sh ?

@khrm
Copy link
Copy Markdown
Contributor

khrm commented Jan 28, 2026

Please separate vendor and code changes into separate PR. It makes it easier to review.

@khrm
Copy link
Copy Markdown
Contributor

khrm commented Feb 4, 2026

Can you rebase this?

Also, ensure that generated related changes are there with vendor update commit.

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 4, 2026
@khrm
Copy link
Copy Markdown
Contributor

khrm commented Feb 4, 2026

Did you test the metrics? Can you write release note which mention any changes/breaking changes that user need to make?

@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 11, 2026
@infernus01 infernus01 force-pushed the migration-otel branch 2 times, most recently from a44aee6 to b91b547 Compare February 16, 2026 12:33
@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 18, 2026
@tekton-robot tekton-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 27, 2026
@infernus01 infernus01 force-pushed the migration-otel branch 2 times, most recently from 6877d78 to cd764a0 Compare March 3, 2026 13:39
@tekton-robot tekton-robot added release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesnt merit a release note. labels Mar 3, 2026
@infernus01 infernus01 changed the title WIP: Migration from OpenCensus to OpenTelemetry feat(metrics): Migration from OpenCensus to OpenTelemetry Mar 4, 2026
@infernus01 infernus01 marked this pull request as ready for review March 4, 2026 05:08
@infernus01 infernus01 requested a review from khrm March 24, 2026 10:09
@infernus01 infernus01 force-pushed the migration-otel branch 2 times, most recently from d483a25 to 835e347 Compare March 24, 2026 10:31
Comment thread go.mod Outdated
Comment thread docs/metrics.md Outdated
Comment thread pkg/reconciler/metrics/metrics.go Outdated
Comment thread pkg/sink/metrics.go Outdated
Comment thread pkg/sink/metrics.go Outdated
Comment thread pkg/reconciler/metrics/metrics.go Outdated
Comment thread pkg/reconciler/metrics/metrics.go Outdated
Comment thread pkg/reconciler/metrics/metrics.go Outdated
Comment thread pkg/reconciler/metrics/metrics.go Outdated
infernus01 and others added 2 commits March 31, 2026 00:31
The OTel migration bumped knative.dev/eventing to a version
  that starts a health probe server on port 8080 inside MainWithInformers.
  The event-listener sink's own HTTP server also listens on port 8080,
  causing "bind: address already in use" on startup, putting el-* pods
  into CrashLoopBackOff and breaking e2e tests.

Co-authored-by: Khurram Baig <kbaig@redhat.com>
Co-authored-by: Shubham Bhardwaj <shubbhar@redhat.com>
Bump knative and Pipeline to latest. Also ran ./hack/update-codegen.sh.

Co-authored-by: Shubham Bhardwaj <shubbhar@redhat.com>
Co-authored-by: Khurram Baig <kbaig@redhat.com>
@khrm
Copy link
Copy Markdown
Contributor

khrm commented Mar 30, 2026

Instead of having event_received_count_total, it's better to have event_received_total.

infernus01 and others added 2 commits March 31, 2026 01:03
Migration from OpenCensus to OTEL

Co-authored-by: Shubham Bhardwaj <shubbhar@redhat.com>
Co-authored-by: Khurram Baig <kbaig@redhat.com>
Co-authored-by: Shubham Bhardwaj <shubbhar@redhat.com>
Co-authored-by: Khurram Baig <kbaig@redhat.com>
@infernus01
Copy link
Copy Markdown
Member Author

Thanks @khrm for a thorough review!

@khrm
Copy link
Copy Markdown
Contributor

khrm commented Mar 31, 2026

I have updated the release note. Will merge soon.

Copy link
Copy Markdown
Contributor

@khrm khrm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@tekton-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: khrm

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 31, 2026
@khrm
Copy link
Copy Markdown
Contributor

khrm commented Mar 31, 2026

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 31, 2026
@tekton-robot tekton-robot merged commit b293c22 into tektoncd:main Mar 31, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate metrics from OpenCensus to OpenTelemetry

5 participants