Skip to content

test: add e2e test for OpenCensus to OpenTelemetry metrics migration#2055

Open
khrm wants to merge 1 commit into
tektoncd:mainfrom
khrm:e2e-otel-metrics-test
Open

test: add e2e test for OpenCensus to OpenTelemetry metrics migration#2055
khrm wants to merge 1 commit into
tektoncd:mainfrom
khrm:e2e-otel-metrics-test

Conversation

@khrm

@khrm khrm commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Adds TestOTelMetrics, a consolidated e2e test for the OC→OTel metrics migration in Triggers (PR #1934). The test creates minimal Triggers resources (TriggerTemplate with a TaskRun, TriggerBinding, EventListener) and scrapes the controller /metrics endpoint on port 9000 to assert:

  • All controller gauge metrics are registered (eventlistener_count, triggerbinding_count, clustertriggerbinding_count, triggertemplate_count, clusterinterceptor_count)
  • Knative workqueue metrics use the new kn_workqueue_* prefix
  • Standard go_* runtime metrics are present
  • Old OpenCensus metric names (tekton_triggers_controller_workqueue_*) are absent

Uses expfmt/dto.MetricFamily for proper Prometheus text parsing against the controller pod's metrics endpoint (port 9000, labeled app.kubernetes.io/part-of=tekton-triggers).

Relates to #1934

Changes

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

NONE

@tekton-robot tekton-robot added the release-note-none Denotes a PR that doesnt merit a release note. label Jun 29, 2026
@tekton-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please ask for approval from khrm after the PR has been reviewed.

The full list of commands accepted by this bot can be found 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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 29, 2026
@khrm
khrm requested a review from Copilot June 29, 2026 11:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds an end-to-end test to validate the OpenCensus → OpenTelemetry metrics migration for Tekton Triggers by scraping the controller’s /metrics endpoint and asserting expected metric family presence/prefixes and absence of legacy OpenCensus names.

Changes:

  • Introduces a new TestOTelMetrics e2e test that creates minimal Triggers resources (TriggerTemplate/TriggerBinding/EventListener).
  • Scrapes and parses Prometheus text metrics from the controller (port 9000) via the Kubernetes API proxy and asserts expected metric naming/presence.
  • Adds explicit checks that legacy OpenCensus workqueue metric names are absent.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/metrics_otel_test.go Outdated
Comment on lines +272 to +283
t.Run("Renames/workqueue_uses_kn_prefix", func(t *testing.T) {
found := false
for name := range families {
if strings.HasPrefix(name, "kn_workqueue_") {
found = true
break
}
}
if !found {
t.Error("Expected at least one kn_workqueue_* metric, found none")
}
})
@khrm
khrm force-pushed the e2e-otel-metrics-test branch 9 times, most recently from 4ecec08 to 6284b15 Compare June 30, 2026 15:39
@tekton-robot tekton-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 30, 2026
@khrm
khrm force-pushed the e2e-otel-metrics-test branch from 6284b15 to b9a2f8d Compare June 30, 2026 15:41
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 30, 2026
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@khrm
khrm force-pushed the e2e-otel-metrics-test branch from b9a2f8d to 3ff6e30 Compare July 21, 2026 12:52
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 31.92%. Comparing base (511e6f6) to head (3ff6e30).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2055   +/-   ##
=======================================
  Coverage   31.92%   31.92%           
=======================================
  Files         260      260           
  Lines       11966    11966           
=======================================
  Hits         3820     3820           
  Misses       7827     7827           
  Partials      319      319           
Flag Coverage Δ
unit-tests 31.92% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note-none Denotes a PR that doesnt merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants