Skip to content

Commit 5d4f634

Browse files
authored
[1.18] 6748-spawn-upstream-span-backport (#10566)
1 parent db4142d commit 5d4f634

File tree

13 files changed

+99
-12
lines changed

13 files changed

+99
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
changelog:
3+
- type: FIX
4+
issueLink: https://github.com/solo-io/solo-projects/issues/6748
5+
resolvesIssue: true
6+
description: >
7+
Expose spawn_upstream_span on the tracing API. This setting tells
8+
envoy to spawn a new span for each upstream request.
9+
10+

docs/content/reference/api/github.com/solo-io/gloo/projects/gloo/api/v1/options/tracing/tracing.proto.sk.md

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install/helm/gloo/crds/gateway.solo.io_v1_Gateway.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,8 @@ spec:
11431143
nullable: true
11441144
type: string
11451145
type: array
1146+
spawnUpstreamSpan:
1147+
type: boolean
11461148
tracePercentages:
11471149
properties:
11481150
clientSamplePercentage:
@@ -1821,6 +1823,8 @@ spec:
18211823
nullable: true
18221824
type: string
18231825
type: array
1826+
spawnUpstreamSpan:
1827+
type: boolean
18241828
tracePercentages:
18251829
properties:
18261830
clientSamplePercentage:
@@ -3165,6 +3169,8 @@ spec:
31653169
nullable: true
31663170
type: string
31673171
type: array
3172+
spawnUpstreamSpan:
3173+
type: boolean
31683174
tracePercentages:
31693175
properties:
31703176
clientSamplePercentage:

install/helm/gloo/crds/gateway.solo.io_v1_HttpListenerOption.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,8 @@ spec:
11341134
nullable: true
11351135
type: string
11361136
type: array
1137+
spawnUpstreamSpan:
1138+
type: boolean
11371139
tracePercentages:
11381140
properties:
11391141
clientSamplePercentage:

install/helm/gloo/crds/gateway.solo.io_v1_MatchableHttpGateway.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,8 @@ spec:
11371137
nullable: true
11381138
type: string
11391139
type: array
1140+
spawnUpstreamSpan:
1141+
type: boolean
11401142
tracePercentages:
11411143
properties:
11421144
clientSamplePercentage:

projects/gloo/api/v1/options/tracing/tracing.proto

+5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ message ListenerTracingSettings {
4343
repeated TracingTagEnvironmentVariable environment_variables_for_tags = 6;
4444
// Optional. If specified, Envoy will include the literals with the given tag as tracing tags.
4545
repeated TracingTagLiteral literals_for_tags = 7;
46+
47+
// Optional
48+
// 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
49+
// will be independent hop in the trace chain and may set span type to client or server based on this flag.
50+
bool spawn_upstream_span = 10;
4651
}
4752

4853
// Contains settings for configuring Envoy's tracing capabilities at the route level.

projects/gloo/pkg/api/v1/options/tracing/tracing.pb.clone.go

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/gloo/pkg/api/v1/options/tracing/tracing.pb.equal.go

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/gloo/pkg/api/v1/options/tracing/tracing.pb.go

+16-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/gloo/pkg/api/v1/options/tracing/tracing.pb.hash.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/gloo/pkg/api/v1/options/tracing/tracing.pb.uniquehash.go

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/gloo/pkg/plugins/tracing/plugin.go

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/solo-io/gloo/projects/gloo/pkg/plugins/pluginutils"
2020
translatorutil "github.com/solo-io/gloo/projects/gloo/pkg/translator"
2121
"github.com/solo-io/solo-kit/pkg/api/v1/resources/core"
22+
"google.golang.org/protobuf/types/known/wrapperspb"
2223
)
2324

2425
var (
@@ -86,6 +87,7 @@ func (p *plugin) ProcessHcmNetworkFilter(params plugins.Params, parent *v1.Liste
8687
trCfg.RandomSampling = envoySimplePercent(oneHundredPercent)
8788
trCfg.OverallSampling = envoySimplePercent(oneHundredPercent)
8889
}
90+
trCfg.SpawnUpstreamSpan = wrapperspb.Bool(tracingSettings.GetSpawnUpstreamSpan())
8991
out.Tracing = trCfg
9092
return nil
9193
}

projects/gloo/pkg/plugins/tracing/plugin_test.go

+35-10
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,12 @@ var _ = Describe("Plugin", func() {
151151
},
152152
},
153153
},
154-
ClientSampling: &envoy_type.Percent{Value: 10},
155-
RandomSampling: &envoy_type.Percent{Value: 20},
156-
OverallSampling: &envoy_type.Percent{Value: 30},
157-
Verbose: true,
158-
Provider: nil,
154+
ClientSampling: &envoy_type.Percent{Value: 10},
155+
RandomSampling: &envoy_type.Percent{Value: 20},
156+
OverallSampling: &envoy_type.Percent{Value: 30},
157+
Verbose: true,
158+
Provider: nil,
159+
SpawnUpstreamSpan: &wrappers.BoolValue{Value: false},
159160
},
160161
}
161162
Expect(cfg).To(Equal(expected))
@@ -171,11 +172,35 @@ var _ = Describe("Plugin", func() {
171172
Expect(err).NotTo(HaveOccurred())
172173
expected := &envoyhttp.HttpConnectionManager{
173174
Tracing: &envoyhttp.HttpConnectionManager_Tracing{
174-
ClientSampling: &envoy_type.Percent{Value: 100},
175-
RandomSampling: &envoy_type.Percent{Value: 100},
176-
OverallSampling: &envoy_type.Percent{Value: 100},
177-
Verbose: false,
178-
Provider: nil,
175+
ClientSampling: &envoy_type.Percent{Value: 100},
176+
RandomSampling: &envoy_type.Percent{Value: 100},
177+
OverallSampling: &envoy_type.Percent{Value: 100},
178+
Verbose: false,
179+
Provider: nil,
180+
SpawnUpstreamSpan: &wrappers.BoolValue{Value: false},
181+
},
182+
}
183+
Expect(cfg).To(Equal(expected))
184+
})
185+
186+
It("should properly set spawn_upstream_span", func() {
187+
cfg := &envoyhttp.HttpConnectionManager{}
188+
hcmSettings = &hcm.HttpConnectionManagerSettings{
189+
Tracing: &tracing.ListenerTracingSettings{
190+
SpawnUpstreamSpan: true,
191+
},
192+
}
193+
194+
err := processHcmNetworkFilter(cfg)
195+
Expect(err).NotTo(HaveOccurred())
196+
expected := &envoyhttp.HttpConnectionManager{
197+
Tracing: &envoyhttp.HttpConnectionManager_Tracing{
198+
ClientSampling: &envoy_type.Percent{Value: 100},
199+
RandomSampling: &envoy_type.Percent{Value: 100},
200+
OverallSampling: &envoy_type.Percent{Value: 100},
201+
Verbose: false,
202+
Provider: nil,
203+
SpawnUpstreamSpan: &wrappers.BoolValue{Value: true},
179204
},
180205
}
181206
Expect(cfg).To(Equal(expected))

0 commit comments

Comments
 (0)