Skip to content

Commit

Permalink
[1.18] 6748-spawn-upstream-span-backport (#10566)
Browse files Browse the repository at this point in the history
  • Loading branch information
EItanya authored Jan 10, 2025
1 parent db4142d commit 5d4f634
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 12 deletions.
10 changes: 10 additions & 0 deletions changelog/v1.18.4/6748-spawn-upstream-span-backport.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

changelog:
- type: FIX
issueLink: https://github.com/solo-io/solo-projects/issues/6748
resolvesIssue: true
description: >
Expose spawn_upstream_span on the tracing API. This setting tells
envoy to spawn a new span for each upstream request.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions install/helm/gloo/crds/gateway.solo.io_v1_Gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,8 @@ spec:
nullable: true
type: string
type: array
spawnUpstreamSpan:
type: boolean
tracePercentages:
properties:
clientSamplePercentage:
Expand Down Expand Up @@ -1821,6 +1823,8 @@ spec:
nullable: true
type: string
type: array
spawnUpstreamSpan:
type: boolean
tracePercentages:
properties:
clientSamplePercentage:
Expand Down Expand Up @@ -3165,6 +3169,8 @@ spec:
nullable: true
type: string
type: array
spawnUpstreamSpan:
type: boolean
tracePercentages:
properties:
clientSamplePercentage:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,8 @@ spec:
nullable: true
type: string
type: array
spawnUpstreamSpan:
type: boolean
tracePercentages:
properties:
clientSamplePercentage:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,8 @@ spec:
nullable: true
type: string
type: array
spawnUpstreamSpan:
type: boolean
tracePercentages:
properties:
clientSamplePercentage:
Expand Down
5 changes: 5 additions & 0 deletions projects/gloo/api/v1/options/tracing/tracing.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ message ListenerTracingSettings {
repeated TracingTagEnvironmentVariable environment_variables_for_tags = 6;
// Optional. If specified, Envoy will include the literals with the given tag as tracing tags.
repeated TracingTagLiteral literals_for_tags = 7;

// Optional
// Create separate tracing span for each upstream request if true. And if this flag is set to true, the tracing provider will assume that Envoy
// will be independent hop in the trace chain and may set span type to client or server based on this flag.
bool spawn_upstream_span = 10;
}

// Contains settings for configuring Envoy's tracing capabilities at the route level.
Expand Down
2 changes: 2 additions & 0 deletions projects/gloo/pkg/api/v1/options/tracing/tracing.pb.clone.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions projects/gloo/pkg/api/v1/options/tracing/tracing.pb.equal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions projects/gloo/pkg/api/v1/options/tracing/tracing.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions projects/gloo/pkg/api/v1/options/tracing/tracing.pb.hash.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions projects/gloo/pkg/plugins/tracing/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/solo-io/gloo/projects/gloo/pkg/plugins/pluginutils"
translatorutil "github.com/solo-io/gloo/projects/gloo/pkg/translator"
"github.com/solo-io/solo-kit/pkg/api/v1/resources/core"
"google.golang.org/protobuf/types/known/wrapperspb"
)

var (
Expand Down Expand Up @@ -86,6 +87,7 @@ func (p *plugin) ProcessHcmNetworkFilter(params plugins.Params, parent *v1.Liste
trCfg.RandomSampling = envoySimplePercent(oneHundredPercent)
trCfg.OverallSampling = envoySimplePercent(oneHundredPercent)
}
trCfg.SpawnUpstreamSpan = wrapperspb.Bool(tracingSettings.GetSpawnUpstreamSpan())
out.Tracing = trCfg
return nil
}
Expand Down
45 changes: 35 additions & 10 deletions projects/gloo/pkg/plugins/tracing/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,12 @@ var _ = Describe("Plugin", func() {
},
},
},
ClientSampling: &envoy_type.Percent{Value: 10},
RandomSampling: &envoy_type.Percent{Value: 20},
OverallSampling: &envoy_type.Percent{Value: 30},
Verbose: true,
Provider: nil,
ClientSampling: &envoy_type.Percent{Value: 10},
RandomSampling: &envoy_type.Percent{Value: 20},
OverallSampling: &envoy_type.Percent{Value: 30},
Verbose: true,
Provider: nil,
SpawnUpstreamSpan: &wrappers.BoolValue{Value: false},
},
}
Expect(cfg).To(Equal(expected))
Expand All @@ -171,11 +172,35 @@ var _ = Describe("Plugin", func() {
Expect(err).NotTo(HaveOccurred())
expected := &envoyhttp.HttpConnectionManager{
Tracing: &envoyhttp.HttpConnectionManager_Tracing{
ClientSampling: &envoy_type.Percent{Value: 100},
RandomSampling: &envoy_type.Percent{Value: 100},
OverallSampling: &envoy_type.Percent{Value: 100},
Verbose: false,
Provider: nil,
ClientSampling: &envoy_type.Percent{Value: 100},
RandomSampling: &envoy_type.Percent{Value: 100},
OverallSampling: &envoy_type.Percent{Value: 100},
Verbose: false,
Provider: nil,
SpawnUpstreamSpan: &wrappers.BoolValue{Value: false},
},
}
Expect(cfg).To(Equal(expected))
})

It("should properly set spawn_upstream_span", func() {
cfg := &envoyhttp.HttpConnectionManager{}
hcmSettings = &hcm.HttpConnectionManagerSettings{
Tracing: &tracing.ListenerTracingSettings{
SpawnUpstreamSpan: true,
},
}

err := processHcmNetworkFilter(cfg)
Expect(err).NotTo(HaveOccurred())
expected := &envoyhttp.HttpConnectionManager{
Tracing: &envoyhttp.HttpConnectionManager_Tracing{
ClientSampling: &envoy_type.Percent{Value: 100},
RandomSampling: &envoy_type.Percent{Value: 100},
OverallSampling: &envoy_type.Percent{Value: 100},
Verbose: false,
Provider: nil,
SpawnUpstreamSpan: &wrappers.BoolValue{Value: true},
},
}
Expect(cfg).To(Equal(expected))
Expand Down

0 comments on commit 5d4f634

Please sign in to comment.