-
Notifications
You must be signed in to change notification settings - Fork 444
/
trace.go
42 lines (37 loc) · 2.01 KB
/
trace.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package api_conversion
import (
envoytrace "github.com/envoyproxy/go-control-plane/envoy/config/trace/v3"
envoytrace_gloo "github.com/solo-io/gloo/projects/gloo/pkg/api/external/envoy/config/trace/v3"
)
// Converts between Envoy and Gloo/solokit versions of envoy protos
// This is required because go-control-plane dropped gogoproto in favor of goproto
// in v0.9.0, but solokit depends on gogoproto (and the generated deep equals it creates).
//
// we should work to remove that assumption from solokit and delete this code:
// https://github.com/solo-io/gloo/issues/1793
func ToEnvoyDatadogConfiguration(glooDatadogConfig *envoytrace_gloo.DatadogConfig, clusterName string) (*envoytrace.DatadogConfig, error) {
envoyDatadogConfig := &envoytrace.DatadogConfig{
CollectorCluster: clusterName,
ServiceName: glooDatadogConfig.GetServiceName().GetValue(),
}
return envoyDatadogConfig, nil
}
func ToEnvoyZipkinConfiguration(glooZipkinConfig *envoytrace_gloo.ZipkinConfig, clusterName string) (*envoytrace.ZipkinConfig, error) {
envoyZipkinConfig := &envoytrace.ZipkinConfig{
CollectorCluster: clusterName,
CollectorEndpoint: glooZipkinConfig.GetCollectorEndpoint(),
CollectorEndpointVersion: ToEnvoyZipkinCollectorEndpointVersion(glooZipkinConfig.GetCollectorEndpointVersion()),
TraceId_128Bit: glooZipkinConfig.GetTraceId_128Bit().GetValue(),
SharedSpanContext: glooZipkinConfig.GetSharedSpanContext(),
}
return envoyZipkinConfig, nil
}
func ToEnvoyZipkinCollectorEndpointVersion(version envoytrace_gloo.ZipkinConfig_CollectorEndpointVersion) envoytrace.ZipkinConfig_CollectorEndpointVersion {
switch str := version.String(); str {
case envoytrace_gloo.ZipkinConfig_CollectorEndpointVersion_name[int32(envoytrace_gloo.ZipkinConfig_HTTP_JSON)]:
return envoytrace.ZipkinConfig_HTTP_JSON
case envoytrace_gloo.ZipkinConfig_CollectorEndpointVersion_name[int32(envoytrace_gloo.ZipkinConfig_HTTP_PROTO)]:
return envoytrace.ZipkinConfig_HTTP_PROTO
}
return envoytrace.ZipkinConfig_HTTP_JSON
}