Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Separating tracing/zipkin specific code #1322

Merged
merged 1 commit into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 2 additions & 21 deletions pkg/envoy/lds/connection_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
39 changes: 39 additions & 0 deletions pkg/envoy/lds/tracing.go
Original file line number Diff line number Diff line change
@@ -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
}