diff --git a/pkg/envoy/lds/connection_manager.go b/pkg/envoy/lds/connection_manager.go index 38c51ffa95..42d60961b2 100644 --- a/pkg/envoy/lds/connection_manager.go +++ b/pkg/envoy/lds/connection_manager.go @@ -2,11 +2,9 @@ package lds import ( xds_route "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" - xds_tracing "github.com/envoyproxy/go-control-plane/envoy/config/trace/v3" xds_hcm "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3" "github.com/envoyproxy/go-control-plane/pkg/wellknown" - "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/wrappers" "github.com/openservicemesh/osm/pkg/configurator" @@ -40,29 +38,12 @@ func getHTTPConnectionManager(routeName string, cfg configurator.Configurator) * Value: true, } - zipkinConf := &xds_tracing.ZipkinConfig{ - CollectorCluster: constants.EnvoyZipkinCluster, - CollectorEndpoint: cfg.GetZipkinEndpoint(), - CollectorEndpointVersion: xds_tracing.ZipkinConfig_HTTP_JSON, - } - - zipkinConfMarshalled, err := ptypes.MarshalAny(zipkinConf) + tracing, err := GetZipkinTracingConfig(cfg) if err != nil { - log.Error().Err(err).Msgf("Error marshalling zipkinConf config %s", err) + log.Error().Err(err).Msgf("Error getting zipkin tracing config %s", err) return connManager } - tracing := &xds_hcm.HttpConnectionManager_Tracing{ - Verbose: true, - Provider: &xds_tracing.Tracing_Http{ - // Name must refer to an instantiatable tracing driver - Name: "envoy.tracers.zipkin", - ConfigType: &xds_tracing.Tracing_Http_TypedConfig{ - TypedConfig: zipkinConfMarshalled, - }, - }, - } - connManager.Tracing = tracing } diff --git a/pkg/envoy/lds/tracing.go b/pkg/envoy/lds/tracing.go new file mode 100644 index 0000000000..d917167087 --- /dev/null +++ b/pkg/envoy/lds/tracing.go @@ -0,0 +1,39 @@ +package lds + +import ( + xds_tracing "github.com/envoyproxy/go-control-plane/envoy/config/trace/v3" + xds_hcm "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3" + + "github.com/golang/protobuf/ptypes" + "github.com/openservicemesh/osm/pkg/configurator" + "github.com/openservicemesh/osm/pkg/constants" +) + +// GetZipkinTracingConfig returns a configuration tracing struct for a connection manager to use +func GetZipkinTracingConfig(cfg configurator.Configurator) (*xds_hcm.HttpConnectionManager_Tracing, error) { + + zipkinConf := &xds_tracing.ZipkinConfig{ + CollectorCluster: constants.EnvoyZipkinCluster, + CollectorEndpoint: cfg.GetZipkinEndpoint(), + CollectorEndpointVersion: xds_tracing.ZipkinConfig_HTTP_JSON, + } + + zipkinConfMarshalled, err := ptypes.MarshalAny(zipkinConf) + if err != nil { + log.Error().Err(err).Msgf("Error marshalling zipkinConf config %s", err) + return nil, err + } + + tracing := &xds_hcm.HttpConnectionManager_Tracing{ + Verbose: true, + Provider: &xds_tracing.Tracing_Http{ + // Name must refer to an instantiatable tracing driver + Name: "envoy.tracers.zipkin", + ConfigType: &xds_tracing.Tracing_Http_TypedConfig{ + TypedConfig: zipkinConfMarshalled, + }, + }, + } + + return tracing, nil +}