mirror of
https://github.com/alibaba/higress.git
synced 2026-05-31 08:07:26 +08:00
fix: add HTTP2 protocol options to skywalking and otel cluster (#1379)
This commit is contained in:
@@ -72,17 +72,17 @@ go.test.coverage: prebuild
|
|||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: prebuild $(OUT)
|
build: prebuild $(OUT)
|
||||||
GOPROXY=$(GOPROXY) GOOS=$(GOOS_LOCAL) GOARCH=$(GOARCH_LOCAL) LDFLAGS=$(RELEASE_LDFLAGS) tools/hack/gobuild.sh $(OUT)/ $(HIGRESS_BINARIES)
|
GOPROXY="$(GOPROXY)" GOOS=$(GOOS_LOCAL) GOARCH=$(GOARCH_LOCAL) LDFLAGS=$(RELEASE_LDFLAGS) tools/hack/gobuild.sh $(OUT)/ $(HIGRESS_BINARIES)
|
||||||
|
|
||||||
.PHONY: build-linux
|
.PHONY: build-linux
|
||||||
build-linux: prebuild $(OUT)
|
build-linux: prebuild $(OUT)
|
||||||
GOPROXY=$(GOPROXY) GOOS=linux GOARCH=$(GOARCH_LOCAL) LDFLAGS=$(RELEASE_LDFLAGS) tools/hack/gobuild.sh $(OUT_LINUX)/ $(HIGRESS_BINARIES)
|
GOPROXY="$(GOPROXY)" GOOS=linux GOARCH=$(GOARCH_LOCAL) LDFLAGS=$(RELEASE_LDFLAGS) tools/hack/gobuild.sh $(OUT_LINUX)/ $(HIGRESS_BINARIES)
|
||||||
|
|
||||||
$(AMD64_OUT_LINUX)/higress:
|
$(AMD64_OUT_LINUX)/higress:
|
||||||
GOPROXY=$(GOPROXY) GOOS=linux GOARCH=amd64 LDFLAGS=$(RELEASE_LDFLAGS) tools/hack/gobuild.sh ./out/linux_amd64/ $(HIGRESS_BINARIES)
|
GOPROXY="$(GOPROXY)" GOOS=linux GOARCH=amd64 LDFLAGS=$(RELEASE_LDFLAGS) tools/hack/gobuild.sh ./out/linux_amd64/ $(HIGRESS_BINARIES)
|
||||||
|
|
||||||
$(ARM64_OUT_LINUX)/higress:
|
$(ARM64_OUT_LINUX)/higress:
|
||||||
GOPROXY=$(GOPROXY) GOOS=linux GOARCH=arm64 LDFLAGS=$(RELEASE_LDFLAGS) tools/hack/gobuild.sh ./out/linux_arm64/ $(HIGRESS_BINARIES)
|
GOPROXY="$(GOPROXY)" GOOS=linux GOARCH=arm64 LDFLAGS=$(RELEASE_LDFLAGS) tools/hack/gobuild.sh ./out/linux_arm64/ $(HIGRESS_BINARIES)
|
||||||
|
|
||||||
.PHONY: build-hgctl
|
.PHONY: build-hgctl
|
||||||
build-hgctl: prebuild $(OUT)
|
build-hgctl: prebuild $(OUT)
|
||||||
|
|||||||
@@ -255,14 +255,7 @@ func (t *TracingController) ConstructEnvoyFilters() ([]*config.Config, error) {
|
|||||||
return configs, nil
|
return configs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
config := &config.Config{
|
configPatches := []*networking.EnvoyFilter_EnvoyConfigObjectPatch{
|
||||||
Meta: config.Meta{
|
|
||||||
GroupVersionKind: gvk.EnvoyFilter,
|
|
||||||
Name: higressTracingEnvoyFilterName,
|
|
||||||
Namespace: namespace,
|
|
||||||
},
|
|
||||||
Spec: &networking.EnvoyFilter{
|
|
||||||
ConfigPatches: []*networking.EnvoyFilter_EnvoyConfigObjectPatch{
|
|
||||||
{
|
{
|
||||||
ApplyTo: networking.EnvoyFilter_NETWORK_FILTER,
|
ApplyTo: networking.EnvoyFilter_NETWORK_FILTER,
|
||||||
Match: &networking.EnvoyFilter_EnvoyConfigObjectMatch{
|
Match: &networking.EnvoyFilter_EnvoyConfigObjectMatch{
|
||||||
@@ -310,7 +303,19 @@ func (t *TracingController) ConstructEnvoyFilters() ([]*config.Config, error) {
|
|||||||
}`),
|
}`),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
patches := t.constructTracingExtendPatches(tracing)
|
||||||
|
configPatches = append(configPatches, patches...)
|
||||||
|
|
||||||
|
config := &config.Config{
|
||||||
|
Meta: config.Meta{
|
||||||
|
GroupVersionKind: gvk.EnvoyFilter,
|
||||||
|
Name: higressTracingEnvoyFilterName,
|
||||||
|
Namespace: namespace,
|
||||||
},
|
},
|
||||||
|
Spec: &networking.EnvoyFilter{
|
||||||
|
ConfigPatches: configPatches,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,6 +323,52 @@ func (t *TracingController) ConstructEnvoyFilters() ([]*config.Config, error) {
|
|||||||
return configs, nil
|
return configs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func tracingClusterName(port, service string) string {
|
||||||
|
return fmt.Sprintf("outbound|%s||%s", port, service)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TracingController) constructHTTP2ProtocolOptionsPatch(port, service string) *networking.EnvoyFilter_EnvoyConfigObjectPatch {
|
||||||
|
http2ProtocolOptions := `{"typed_extension_protocol_options": {
|
||||||
|
"envoy.extensions.upstreams.http.v3.HttpProtocolOptions": {
|
||||||
|
"@type": "type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions",
|
||||||
|
"explicit_http_config": {
|
||||||
|
"http2_protocol_options": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}`
|
||||||
|
|
||||||
|
return &networking.EnvoyFilter_EnvoyConfigObjectPatch{
|
||||||
|
ApplyTo: networking.EnvoyFilter_CLUSTER,
|
||||||
|
Match: &networking.EnvoyFilter_EnvoyConfigObjectMatch{
|
||||||
|
Context: networking.EnvoyFilter_GATEWAY,
|
||||||
|
ObjectTypes: &networking.EnvoyFilter_EnvoyConfigObjectMatch_Cluster{
|
||||||
|
Cluster: &networking.EnvoyFilter_ClusterMatch{
|
||||||
|
Name: tracingClusterName(port, service),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Patch: &networking.EnvoyFilter_Patch{
|
||||||
|
Operation: networking.EnvoyFilter_Patch_MERGE,
|
||||||
|
Value: util.BuildPatchStruct(http2ProtocolOptions),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TracingController) constructTracingExtendPatches(tracing *Tracing) []*networking.EnvoyFilter_EnvoyConfigObjectPatch {
|
||||||
|
if tracing == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var patches []*networking.EnvoyFilter_EnvoyConfigObjectPatch
|
||||||
|
if skywalking := tracing.Skywalking; skywalking != nil {
|
||||||
|
patches = append(patches, t.constructHTTP2ProtocolOptionsPatch(skywalking.Port, skywalking.Service))
|
||||||
|
}
|
||||||
|
if otel := tracing.OpenTelemetry; otel != nil {
|
||||||
|
patches = append(patches, t.constructHTTP2ProtocolOptionsPatch(otel.Port, otel.Service))
|
||||||
|
}
|
||||||
|
|
||||||
|
return patches
|
||||||
|
}
|
||||||
|
|
||||||
func (t *TracingController) constructTracingTracer(tracing *Tracing, namespace string) string {
|
func (t *TracingController) constructTracingTracer(tracing *Tracing, namespace string) string {
|
||||||
tracingConfig := ""
|
tracingConfig := ""
|
||||||
timeout := float32(tracing.Timeout) / 1000
|
timeout := float32(tracing.Timeout) / 1000
|
||||||
@@ -338,7 +389,7 @@ func (t *TracingController) constructTracingTracer(tracing *Tracing, namespace s
|
|||||||
},
|
},
|
||||||
"grpc_service": {
|
"grpc_service": {
|
||||||
"envoy_grpc": {
|
"envoy_grpc": {
|
||||||
"cluster_name": "outbound|%s||%s"
|
"cluster_name": "%s"
|
||||||
},
|
},
|
||||||
"timeout": "%.3fs"
|
"timeout": "%.3fs"
|
||||||
}
|
}
|
||||||
@@ -349,7 +400,7 @@ func (t *TracingController) constructTracingTracer(tracing *Tracing, namespace s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`, namespace, skywalking.AccessToken, skywalking.Port, skywalking.Service, timeout, tracing.Sampling)
|
}`, namespace, skywalking.AccessToken, tracingClusterName(skywalking.Port, skywalking.Service), timeout, tracing.Sampling)
|
||||||
}
|
}
|
||||||
|
|
||||||
if tracing.Zipkin != nil {
|
if tracing.Zipkin != nil {
|
||||||
@@ -363,7 +414,7 @@ func (t *TracingController) constructTracingTracer(tracing *Tracing, namespace s
|
|||||||
"name": "envoy.tracers.zipkin",
|
"name": "envoy.tracers.zipkin",
|
||||||
"typed_config": {
|
"typed_config": {
|
||||||
"@type": "type.googleapis.com/envoy.config.trace.v3.ZipkinConfig",
|
"@type": "type.googleapis.com/envoy.config.trace.v3.ZipkinConfig",
|
||||||
"collector_cluster": "outbound|%s||%s",
|
"collector_cluster": "%s",
|
||||||
"collector_endpoint": "/api/v2/spans",
|
"collector_endpoint": "/api/v2/spans",
|
||||||
"collector_hostname": "higress-gateway",
|
"collector_hostname": "higress-gateway",
|
||||||
"collector_endpoint_version": "HTTP_JSON",
|
"collector_endpoint_version": "HTTP_JSON",
|
||||||
@@ -375,7 +426,7 @@ func (t *TracingController) constructTracingTracer(tracing *Tracing, namespace s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`, zipkin.Port, zipkin.Service, tracing.Sampling)
|
}`, tracingClusterName(zipkin.Port, zipkin.Service), tracing.Sampling)
|
||||||
}
|
}
|
||||||
|
|
||||||
if tracing.OpenTelemetry != nil {
|
if tracing.OpenTelemetry != nil {
|
||||||
@@ -392,7 +443,7 @@ func (t *TracingController) constructTracingTracer(tracing *Tracing, namespace s
|
|||||||
"service_name": "higress-gateway.%s",
|
"service_name": "higress-gateway.%s",
|
||||||
"grpc_service": {
|
"grpc_service": {
|
||||||
"envoy_grpc": {
|
"envoy_grpc": {
|
||||||
"cluster_name": "outbound|%s||%s"
|
"cluster_name": "%s"
|
||||||
},
|
},
|
||||||
"timeout": "%.3fs"
|
"timeout": "%.3fs"
|
||||||
}
|
}
|
||||||
@@ -403,7 +454,7 @@ func (t *TracingController) constructTracingTracer(tracing *Tracing, namespace s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`, namespace, opentelemetry.Port, opentelemetry.Service, timeout, tracing.Sampling)
|
}`, namespace, tracingClusterName(opentelemetry.Port, opentelemetry.Service), timeout, tracing.Sampling)
|
||||||
}
|
}
|
||||||
return tracingConfig
|
return tracingConfig
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user