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

Commit

Permalink
Merge pull request #1322 from openservicemesh/trace-zipkin
Browse files Browse the repository at this point in the history
Separating tracing/zipkin specific code
  • Loading branch information
eduser25 authored Aug 4, 2020
2 parents b5ca622 + 66444d0 commit f0dafb3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 21 deletions.
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
}

0 comments on commit f0dafb3

Please sign in to comment.