func appendJaegerTracing()

in agent/envoy_bootstrap/envoy_bootstrap.go [918:982]


func appendJaegerTracing(b *boot.Bootstrap) error {
	port, err := env.OrInt("JAEGER_TRACER_PORT", 9411)
	if err != nil {
		return err
	}
	addr := env.Or("JAEGER_TRACER_ADDRESS", "127.0.0.1")
	// By default, the envoy is bootstrapped to emit Zipkin traces in PROTO format.
	// If this has to be overwritten for use case such as OTel collector where it
	// by default looks for traces in `JSON` format then set the env variable
	// `JAEGER_TRACER_VERSION` to `JSON`/`json`.
	collectorEndpointVersion := trace.ZipkinConfig_HTTP_PROTO
	if strings.Contains(strings.ToLower(env.Get("JAEGER_TRACER_VERSION")), "json") {
		collectorEndpointVersion = trace.ZipkinConfig_HTTP_JSON
	}
	packedCfg, err := anypb.New(&trace.ZipkinConfig{
		CollectorCluster:         "jaeger",
		CollectorEndpoint:        "/api/v2/spans",
		CollectorEndpointVersion: collectorEndpointVersion,
		SharedSpanContext:        wrapperspb.Bool(false),
	})
	if err != nil {
		return err
	}
	bt := &boot.Bootstrap{
		Tracing: &trace.Tracing{
			Http: &trace.Tracing_Http{
				Name: "envoy.tracers.zipkin",
				ConfigType: &trace.Tracing_Http_TypedConfig{
					TypedConfig: packedCfg,
				},
			},
		},
		StaticResources: &boot.Bootstrap_StaticResources{
			Clusters: []*cluster.Cluster{
				&cluster.Cluster{
					Name: "jaeger",
					ConnectTimeout: &durationpb.Duration{
						Seconds: 1,
					},
					ClusterDiscoveryType: &cluster.Cluster_Type{
						Type: cluster.Cluster_STRICT_DNS,
					},
					LbPolicy: cluster.Cluster_ROUND_ROBIN,
					LoadAssignment: &endpoint.ClusterLoadAssignment{
						ClusterName: "jaeger",
						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)
}