Skip to content

fix(adapter): restore source labels on source adapter client metrics - #9608

Open
RajPrakash681 wants to merge 1 commit into
knative:mainfrom
RajPrakash681:fix/source-adapter-metrics
Open

RajPrakash681 wants to merge 1 commit into
knative:mainfrom
RajPrakash681:fix/source-adapter-metrics

Conversation

@RajPrakash681

@RajPrakash681 RajPrakash681 commented Nov 21, 2026 •

Copy link
Copy Markdown

Fixes #9607

Proposed Changes

  • 🐛 The PingSource and ApiServerSource adapters put kn.source.name, kn.source.namespace and cloudevents.type on their http.client.* metrics again. Since otelhttp v0.72.0 the Transport reads these attributes only from the client labeler.
  • Add observability.WithClientLabels, which adds attributes to the client labeler. The adapters use it instead of the server-side helpers, which are unchanged.
  • The PingSource adapter labels each send on its own context. Before, every tick added three more labels to the context shared by all ticks of a PingSource, which was also a data race between ticks.

Pre-review Checklist

  • At least 80% unit test coverage
  • E2E tests for any new behavior
  • Docs PR for any user-facing impact
  • Spec PR for any new API feature
  • Conformance test for any change to the spec

Release Note

PingSource and ApiServerSource adapter metrics have the kn_source_name, kn_source_namespace and cloudevents_type labels again. They were missing in 1.24.0.

Docs

knative/docs#6803

@knative-prow knative-prow Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 21, 2026
@knative-prow

knative-prow Bot commented Nov 21, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: RajPrakash681
Once this PR has been reviewed and has the lgtm label, please assign matzew for approval. For more information see the Code Review Process.

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

@knative-prow

knative-prow Bot commented Nov 21, 2026

Copy link
Copy Markdown

Hi @RajPrakash681. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kahirokunn

Copy link
Copy Markdown
Member

/ok-to-test

@knative-prow knative-prow Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 22, 2026
@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.32%. Comparing base (f819a05) to head (442aea0).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9608      +/-   ##
==========================================
- Coverage   51.33%   51.32%   -0.02%     
==========================================
  Files         412      412              
  Lines       22189    22193       +4     
==========================================
- Hits        11391    11390       -1     
- Misses       9917     9922       +5     
  Partials      881      881              

☔ 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.

@RajPrakash681
RajPrakash681 force-pushed the fix/source-adapter-metrics branch from 442aea0 to 9839eef Compare November 22, 2026 13:36
tick()
tick()

require.Len(t, *events, 2)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we call s.Close() before require.Len to ensure the HTTP handler has finished writing to events before the test reads it?

Signed-off-by: RajPrakash681 <rjnt452@gmail.com>
@RajPrakash681
RajPrakash681 force-pushed the fix/source-adapter-metrics branch from 9839eef to da02fa3 Compare November 27, 2026 11:14
@knative-prow

knative-prow Bot commented Nov 27, 2026

Copy link
Copy Markdown

@RajPrakash681: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
reconciler-tests_eventing_main da02fa3 link true /test reconciler-tests

Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

PingSource and ApiServerSource adapter metrics lost the Source labels in 1.24

2 participants