Add configurable client_sampling and random_sampling for tracing#7373
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7373 +/- ##
==========================================
- Coverage 81.85% 81.18% -0.67%
==========================================
Files 130 130
Lines 15747 15803 +56
==========================================
- Hits 12889 12829 -60
- Misses 2574 2613 +39
- Partials 284 361 +77
🚀 New features to boost your workflow:
|
|
hi @wilsonwu @tsaarni @sunjayBhatia, can I get this reviewed? |
tsaarni
left a comment
There was a problem hiding this comment.
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/site/content/docs/main/config/tracing.md
Lines 12 to 18 in 07a2134
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.
0cb98e2 to
9957099
Compare
|
@tsaarni thanks for the review! I have addressed your comments |
There was a problem hiding this comment.
Thank you @WUMUXIAN!
We should add parameters for the configuration file, for those who do not use ContourConfiguration CRD. Here is diff you could use, with some test changes as well
diff --git a/cmd/contour/servecontext.go b/cmd/contour/servecontext.go
index 8c4ee27d..e7f4a77e 100644
--- a/cmd/contour/servecontext.go
+++ b/cmd/contour/servecontext.go
@@ -413,6 +413,8 @@ func (ctx *serveContext) convertToContourConfigurationSpec() contour_v1alpha1.Co
IncludePodDetail: ctx.Config.Tracing.IncludePodDetail,
ServiceName: ctx.Config.Tracing.ServiceName,
OverallSampling: ctx.Config.Tracing.OverallSampling,
+ ClientSampling: ctx.Config.Tracing.ClientSampling,
+ RandomSampling: ctx.Config.Tracing.RandomSampling,
MaxPathTagLength: ctx.Config.Tracing.MaxPathTagLength,
CustomTags: customTags,
ExtensionService: &contour_v1alpha1.NamespacedName{
diff --git a/cmd/contour/servecontext_test.go b/cmd/contour/servecontext_test.go
index b3dfee1f..a0678f8f 100644
--- a/cmd/contour/servecontext_test.go
+++ b/cmd/contour/servecontext_test.go
@@ -833,6 +833,8 @@ func TestConvertServeContext(t *testing.T) {
IncludePodDetail: ptr.To(false),
ServiceName: ptr.To("contour"),
OverallSampling: ptr.To("100"),
+ ClientSampling: ptr.To("75"),
+ RandomSampling: ptr.To("50"),
MaxPathTagLength: ptr.To(uint32(256)),
CustomTags: []config.CustomTag{
{
@@ -853,6 +855,8 @@ func TestConvertServeContext(t *testing.T) {
IncludePodDetail: ptr.To(false),
ServiceName: ptr.To("contour"),
OverallSampling: ptr.To("100"),
+ ClientSampling: ptr.To("75"),
+ RandomSampling: ptr.To("50"),
MaxPathTagLength: ptr.To(uint32(256)),
CustomTags: []*contour_v1alpha1.CustomTag{
{
diff --git a/pkg/config/parameters.go b/pkg/config/parameters.go
index 1e4c397d..afb0e09b 100644
--- a/pkg/config/parameters.go
+++ b/pkg/config/parameters.go
@@ -727,6 +727,14 @@ type Tracing struct {
// the default value is 100.
OverallSampling *string `yaml:"overallSampling,omitempty"`
+ // ClientSampling defines the sampling rate when x-client-trace-id header is set.
+ // the default value is 100.
+ ClientSampling *string `yaml:"clientSampling,omitempty"`
+
+ // RandomSampling defines the random sampling rate for all requests.
+ // the default value is 100.
+ RandomSampling *string `yaml:"randomSampling,omitempty"`
+
// MaxPathTagLength defines maximum length of the request path
// to extract and include in the HttpUrl tag.
// the default value is 256.
diff --git a/pkg/config/parameters_test.go b/pkg/config/parameters_test.go
index 6d689619..0fd66f82 100644
--- a/pkg/config/parameters_test.go
+++ b/pkg/config/parameters_test.go
@@ -682,6 +682,8 @@ func TestTracingConfigValidation(t *testing.T) {
IncludePodDetail: ptr.To(false),
ServiceName: ptr.To("contour"),
OverallSampling: ptr.To("100"),
+ ClientSampling: ptr.To("50"),
+ RandomSampling: ptr.To("75"),
MaxPathTagLength: ptr.To(uint32(256)),
CustomTags: nil,
ExtensionService: "projectcontour/otel-collector",
@@ -700,6 +702,8 @@ func TestTracingConfigValidation(t *testing.T) {
trace = &Tracing{
IncludePodDetail: ptr.To(false),
OverallSampling: ptr.To("100"),
+ ClientSampling: ptr.To("75"),
+ RandomSampling: ptr.To("50"),
MaxPathTagLength: ptr.To(uint32(256)),
CustomTags: nil,
ExtensionService: "projectcontour/otel-collector",ad61d6c to
c2c907e
Compare
|
@tsaarni addressed the comments again! thank you |
…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 <muxianw@twitter.com>
fa30bc2 to
f03ad29
Compare
|
@tsaarni I also squashed everything into 1 commit as the number has grown quite a bit.. |
Signed-off-by: Muxian Wu <muxianw@twitter.com>
tsaarni
left a comment
There was a problem hiding this comment.
@WUMUXIAN Sorry it took me a while to get back to this. I've added a few more comments.
You can find a diff here that you can use if you want: https://gist.githubusercontent.com/tsaarni/ad3bea53a9ce621444e2caff368d146d/raw/a129a2e3eb44d30381173b5ff75e0a871ce4360b/gistfile0.txt
Signed-off-by: Muxian Wu <muxianw@twitter.com>
6941803 to
6f666eb
Compare
|
@tsaarni addressed comments |
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
Changes
Fixes #7271
Release note: release-note/minor (new feature for enhanced tracing control)
Signed-off-by: Muxian Wu wumuxian1988@gmail.com