Skip to content

Conversation

@WUMUXIAN
Copy link

@WUMUXIAN WUMUXIAN commented Jan 14, 2026

Add configurable client_sampling and random_sampling for tracing
Pull Request Description:
This PR implements the feature requested in issue #7271, allowing users to configure clientSampling and randomSampling rates for Contour's tracing configuration in addition to the existing overallSampling.

Summary

  • Adds ClientSampling and RandomSampling fields to the TracingConfig API struct
  • Updates internal processing to parse and set these values with defaults of 100%
  • Modifies Envoy configuration generation to include the new sampling rates
  • Includes validation for the new fields
  • All tests updated and passing

Changes

  • API: apis/projectcontour/v1alpha1/contourconfig.go
  • Validation: apis/projectcontour/v1alpha1/contourconfig_helpers.go
  • Processing: cmd/contour/serve.go
  • Internal config: internal/xdscache/v3/listener.go, internal/envoy/v3/tracing.go
  • Tests: internal/envoy/v3/tracing_test.go
  • Code generation: Updated deepcopy and other generated files
  • Changelog: changelogs/unreleased/7271-luckyxkw-minor.md

Fixes #7271
Release note: release-note/minor (new feature for enhanced tracing control)

Signed-off-by: Muxian Wu [email protected]

…or tracing

Add ClientSampling and RandomSampling fields to TracingConfig
to allow configurable client_sampling and random_sampling in Envoy tracing.

Updates projectcontour#7271

Signed-off-by: Muxian Wu <[email protected]>
@WUMUXIAN WUMUXIAN requested a review from a team as a code owner January 14, 2026 10:54
@WUMUXIAN WUMUXIAN requested review from sunjayBhatia and tsaarni and removed request for a team January 14, 2026 10:54
@sunjayBhatia sunjayBhatia requested review from a team, rajatvig and wilsonwu and removed request for a team January 14, 2026 10:54
@tsaarni tsaarni added the release-note/minor A minor change that needs about a paragraph of explanation in the release notes. label Jan 14, 2026
@codecov
Copy link

codecov bot commented Jan 14, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.37%. Comparing base (00812a4) to head (6543d89).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
cmd/contour/serve.go 0.00% 8 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7373      +/-   ##
==========================================
- Coverage   81.85%   81.37%   -0.48%     
==========================================
  Files         130      130              
  Lines       15747    15787      +40     
==========================================
- Hits        12889    12846      -43     
- Misses       2574     2606      +32     
- Partials      284      335      +51     
Files with missing lines Coverage Δ
internal/envoy/v3/tracing.go 87.71% <100.00%> (-6.40%) ⬇️
internal/xdscache/v3/listener.go 77.31% <100.00%> (-14.62%) ⬇️
cmd/contour/serve.go 21.44% <0.00%> (-2.17%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@WUMUXIAN
Copy link
Author

hi @wilsonwu @tsaarni @sunjayBhatia, can I get this reviewed?

Copy link
Member

@tsaarni tsaarni left a comment

Choose a reason for hiding this comment

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

Thank you @WUMUXIAN for contributing!

It would be great to add more tests. I think you can add the new parameters to this file to help with the test coverage https://github.com/projectcontour/contour/blob/main/internal/featuretests/v3/tracing_test.go.

We should also add the new parameters to the tracing docs here:

Contour supports configuring envoy to export data to OpenTelemetry, and allows users to customize some configurations.
- Custom service name, the default is `contour`.
- Custom sampling rate, the default is `100`.
- Custom the maximum length of the request path, the default is `256`.
- Customize span tags from literal or request headers.
- Customize whether to include the pod's hostname and namespace.

The changelog check is failing. You need to rename the file to ./changelogs/unreleased/7373-WUMUXIAN-minor.md. Right now it uses a different name.

Also, the DCO check is failing. You can fix this by rewriting your git history to remove the extra opencode plan file from your first commit. Or, you can just add a sign-off to the commit that removes it. We squash the PR at the end anyway, but we need all commits to have a sign-off for the check to pass.

Value: 100.0,
},
ClientSampling: &envoy_type_v3.Percent{
Value: 0.0,
Copy link
Member

Choose a reason for hiding this comment

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

To match the existing OverallSampling in the tests, I think we should set ClientSampling and RandomSampling to 100 in the test setup. This is clearer to read than leaving them uninitialized and having to use 0.0 as the result.

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

Labels

release-note/minor A minor change that needs about a paragraph of explanation in the release notes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tracing should allow configurable client_sampling and random_sampling

3 participants