Skip to content

Commit 376ba90

Browse files
authored
OTEL tracing gRPC Authority setting (#10580)
1 parent 91ba1c5 commit 376ba90

28 files changed

+923
-187
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
changelog:
2+
- type: NEW_FEATURE
3+
description: |
4+
Add support for setting the authority field on gRPC requests made to OTEL Collectors during tracing.
5+
When the authority field is set, the gRPC client will use the specified value as the :authority header
6+
when making requests to the collector. This is useful when the collector is behind a reverse proxy that
7+
requires a specific authority to be set on incoming requests.
8+
issueLink: https://github.com/solo-io/solo-projects/issues/7740
9+
resolvesIssue: true

docs/data/ProtoMap.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,9 @@ apis:
18231823
solo.io.envoy.config.trace.v3.DatadogRemoteConfig:
18241824
relativepath: reference/api/github.com/solo-io/gloo/projects/gloo/api/external/envoy/config/trace/v3/datadog.proto.sk/#DatadogRemoteConfig
18251825
package: solo.io.envoy.config.trace.v3
1826+
solo.io.envoy.config.trace.v3.GrpcService:
1827+
relativepath: reference/api/github.com/solo-io/gloo/projects/gloo/api/external/envoy/config/trace/v3/opentelemetry.proto.sk/#GrpcService
1828+
package: solo.io.envoy.config.trace.v3
18261829
solo.io.envoy.config.trace.v3.OpenCensusConfig:
18271830
relativepath: reference/api/github.com/solo-io/gloo/projects/gloo/api/external/envoy/config/trace/v3/opencensus.proto.sk/#OpenCensusConfig
18281831
package: solo.io.envoy.config.trace.v3

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

+15
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,11 @@ spec:
11581158
namespace:
11591159
type: string
11601160
type: object
1161+
grpcService:
1162+
properties:
1163+
authority:
1164+
type: string
1165+
type: object
11611166
serviceName:
11621167
type: string
11631168
type: object
@@ -1861,6 +1866,11 @@ spec:
18611866
namespace:
18621867
type: string
18631868
type: object
1869+
grpcService:
1870+
properties:
1871+
authority:
1872+
type: string
1873+
type: object
18641874
serviceName:
18651875
type: string
18661876
type: object
@@ -3230,6 +3240,11 @@ spec:
32303240
namespace:
32313241
type: string
32323242
type: object
3243+
grpcService:
3244+
properties:
3245+
authority:
3246+
type: string
3247+
type: object
32333248
serviceName:
32343249
type: string
32353250
type: object

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

+5
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,11 @@ spec:
11491149
namespace:
11501150
type: string
11511151
type: object
1152+
grpcService:
1153+
properties:
1154+
authority:
1155+
type: string
1156+
type: object
11521157
serviceName:
11531158
type: string
11541159
type: object

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

+5
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,11 @@ spec:
11521152
namespace:
11531153
type: string
11541154
type: object
1155+
grpcService:
1156+
properties:
1157+
authority:
1158+
type: string
1159+
type: object
11551160
serviceName:
11561161
type: string
11571162
type: object

pkg/utils/api_conversion/trace.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,13 @@ func gatewayKindsMap() map[string]bool {
124124
}
125125

126126
// ToEnvoyOpenTelemetryConfiguration converts a Gloo OpenTelemetryConfig to an Envoy OpenTelemetryConfig
127-
func ToEnvoyOpenTelemetryConfiguration(clusterName, serviceName string) *envoytrace.OpenTelemetryConfig {
127+
func ToEnvoyOpenTelemetryConfiguration(clusterName, serviceName, authority string) *envoytrace.OpenTelemetryConfig {
128128
envoyOpenTelemetryConfig := &envoytrace.OpenTelemetryConfig{
129129
GrpcService: &envoy_config_core_v3.GrpcService{
130130
TargetSpecifier: &envoy_config_core_v3.GrpcService_EnvoyGrpc_{
131131
EnvoyGrpc: &envoy_config_core_v3.GrpcService_EnvoyGrpc{
132132
ClusterName: clusterName,
133+
Authority: authority,
133134
},
134135
},
135136
},

pkg/utils/api_conversion/trace_test.go

+23-4
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ var _ = Describe("Trace utils", func() {
4545
})
4646

4747
Context("creates the OpenTelemetryConfig", func() {
48+
clusterName := "cluster-name"
49+
serviceName := "service-name"
50+
authority := "authority"
51+
4852
It("calling ToEnvoyOpenTelemetryConfiguration", func() {
49-
clusterName := "cluster-name"
50-
serviceName := "service-name"
5153
expectedConfig := &envoytrace.OpenTelemetryConfig{
5254
GrpcService: &envoy_config_core_v3.GrpcService{
5355
TargetSpecifier: &envoy_config_core_v3.GrpcService_EnvoyGrpc_{
@@ -59,8 +61,25 @@ var _ = Describe("Trace utils", func() {
5961
ServiceName: serviceName,
6062
}
6163

62-
actutalConfig := ToEnvoyOpenTelemetryConfiguration(clusterName, serviceName)
63-
Expect(actutalConfig).To(Equal(expectedConfig))
64+
actualConfig := ToEnvoyOpenTelemetryConfiguration(clusterName, serviceName, "")
65+
Expect(actualConfig).To(Equal(expectedConfig))
66+
})
67+
68+
It("calling ToEnvoyOpenTelemetryConfiguration with authority", func() {
69+
expectedConfig := &envoytrace.OpenTelemetryConfig{
70+
GrpcService: &envoy_config_core_v3.GrpcService{
71+
TargetSpecifier: &envoy_config_core_v3.GrpcService_EnvoyGrpc_{
72+
EnvoyGrpc: &envoy_config_core_v3.GrpcService_EnvoyGrpc{
73+
ClusterName: clusterName,
74+
Authority: authority,
75+
},
76+
},
77+
},
78+
ServiceName: serviceName,
79+
}
80+
81+
actualConfig := ToEnvoyOpenTelemetryConfiguration(clusterName, serviceName, authority)
82+
Expect(actualConfig).To(Equal(expectedConfig))
6483
})
6584
})
6685
})

projects/gloo/api/external/envoy/config/trace/v3/opentelemetry.proto

+12
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ message OpenTelemetryConfig {
3636
// If this is not set it will be automatically set to the name of the
3737
// listener + the namespace of the Gateway object
3838
string service_name = 3;
39+
40+
// Optional. Current only gRPC is supported, but are intentionally using a oneof
41+
// to allow for future support of HTTP. This structure matches Envoy's.
42+
oneof service_type {
43+
// Optional gRPC transport options
44+
GrpcService grpc_service = 4;
45+
}
46+
}
47+
48+
message GrpcService {
49+
// Set the authority header when calling the gRPC service.
50+
string authority = 1;
3951
}
4052

4153
option go_package = "github.com/solo-io/gloo/projects/gloo/pkg/api/external/envoy/config/trace/v3";

projects/gloo/pkg/api/external/envoy/config/trace/v3/opentelemetry.pb.clone.go

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

projects/gloo/pkg/api/external/envoy/config/trace/v3/opentelemetry.pb.equal.go

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

0 commit comments

Comments
 (0)