in agent/envoy_bootstrap/envoy_bootstrap.go [852:916]
func appendDataDogTracing(b *boot.Bootstrap, nodeId string) error {
port, err := env.OrInt("DATADOG_TRACER_PORT", 8126)
if err != nil {
return err
}
addr := env.Or("DATADOG_TRACER_ADDRESS", "127.0.0.1")
// Generate a name for the Envoy segment of the trace
// similarly to how we generate it for X-Ray: meshName/resourceName
// But defer to whatever is specified in the DD_SERVICE env var
serviceName := "envoy"
res, err := getMeshResourceFromNodeId(nodeId)
if err == nil {
serviceName = "envoy-" + res.MeshName + "/" + res.Name
}
packedCfg, err := anypb.New(&trace.DatadogConfig{
CollectorCluster: "datadog_agent",
ServiceName: env.Or("DD_SERVICE", serviceName),
})
if err != nil {
return err
}
bt := &boot.Bootstrap{
Tracing: &trace.Tracing{
Http: &trace.Tracing_Http{
Name: "envoy.tracers.datadog",
ConfigType: &trace.Tracing_Http_TypedConfig{
TypedConfig: packedCfg,
},
},
},
StaticResources: &boot.Bootstrap_StaticResources{
Clusters: []*cluster.Cluster{
&cluster.Cluster{
Name: "datadog_agent",
ConnectTimeout: &durationpb.Duration{
Seconds: 1,
},
ClusterDiscoveryType: &cluster.Cluster_Type{
Type: cluster.Cluster_STRICT_DNS,
},
LbPolicy: cluster.Cluster_ROUND_ROBIN,
LoadAssignment: &endpoint.ClusterLoadAssignment{
ClusterName: "datadog_agent",
Endpoints: []*endpoint.LocalityLbEndpoints{
&endpoint.LocalityLbEndpoints{
LbEndpoints: []*endpoint.LbEndpoint{
&endpoint.LbEndpoint{
HostIdentifier: &endpoint.LbEndpoint_Endpoint{
Endpoint: &endpoint.Endpoint{
Address: buildTcpSocketAddr(addr, port, false),
},
},
},
},
},
},
},
},
},
},
}
return mergeBootstrap(b, bt)
}