diff --git a/docs/user-guide/nginx-configuration/configmap.md b/docs/user-guide/nginx-configuration/configmap.md index 0af29d574f..d39c41adec 100755 --- a/docs/user-guide/nginx-configuration/configmap.md +++ b/docs/user-guide/nginx-configuration/configmap.md @@ -854,6 +854,10 @@ Specifies the endpoint to use when uploading traces to a collector. This takes p Specifies the service name to use for any traces created. _**default:**_ nginx +## jaeger-propagation-format + +Specifies the traceparent/tracestate propagation format. _**default:**_ jaeger + ## jaeger-sampler-type Specifies the sampler to be used when sampling traces. The available samplers are: const, probabilistic, ratelimiting, remote. _**default:**_ const diff --git a/docs/user-guide/third-party-addons/opentracing.md b/docs/user-guide/third-party-addons/opentracing.md index 1f4138250b..3bef8332c7 100644 --- a/docs/user-guide/third-party-addons/opentracing.md +++ b/docs/user-guide/third-party-addons/opentracing.md @@ -64,6 +64,9 @@ jaeger-endpoint # specifies the service name to use for any traces created, Default: nginx jaeger-service-name +# specifies the traceparent/tracestate propagation format +jaeger-propagation-format + # specifies the sampler to be used when sampling traces. # The available samplers are: const, probabilistic, ratelimiting, remote, Default: const jaeger-sampler-type diff --git a/internal/ingress/controller/config/config.go b/internal/ingress/controller/config/config.go index 35691cb55c..dcd70f9c3c 100644 --- a/internal/ingress/controller/config/config.go +++ b/internal/ingress/controller/config/config.go @@ -562,6 +562,9 @@ type Configuration struct { // Default: nginx JaegerServiceName string `json:"jaeger-service-name"` + // JaegerPropagationFormat specifies the traceparent/tracestate propagation format + JaegerPropagationFormat string `json:"jaeger-propagation-format"` + // JaegerSamplerType specifies the sampler to be used when sampling traces. // The available samplers are: const, probabilistic, ratelimiting, remote // Default: const @@ -867,6 +870,7 @@ func NewDefault() Configuration { ZipkinServiceName: "nginx", ZipkinSampleRate: 1.0, JaegerCollectorPort: 6831, + JaegerPropagationFormat: "jaeger", JaegerServiceName: "nginx", JaegerSamplerType: "const", JaegerSamplerParam: "1", diff --git a/internal/ingress/controller/nginx.go b/internal/ingress/controller/nginx.go index cef2853505..664d36b754 100644 --- a/internal/ingress/controller/nginx.go +++ b/internal/ingress/controller/nginx.go @@ -1033,6 +1033,7 @@ const zipkinTmpl = `{ const jaegerTmpl = `{ "service_name": "{{ .JaegerServiceName }}", + "propagation_format": "{{ .JaegerPropagationFormat }}", "sampler": { "type": "{{ .JaegerSamplerType }}", "param": {{ .JaegerSamplerParam }}, diff --git a/test/e2e/settings/opentracing.go b/test/e2e/settings/opentracing.go index 498bc7a401..0fe4e62f66 100644 --- a/test/e2e/settings/opentracing.go +++ b/test/e2e/settings/opentracing.go @@ -17,6 +17,8 @@ limitations under the License. package settings import ( + "fmt" + "net/http" "strings" "time" @@ -31,8 +33,9 @@ const ( zipkinCollectorHost = "zipkin-collector-host" - jaegerCollectorHost = "jaeger-collector-host" - jaegerSamplerHost = "jaeger-sampler-host" + jaegerCollectorHost = "jaeger-collector-host" + jaegerSamplerHost = "jaeger-sampler-host" + jaegerPropagationFormat = "jaeger-propagation-format" // jaegerEndpoint = "jaeger-endpoint" datadogCollectorHost = "datadog-collector-host" @@ -175,6 +178,36 @@ var _ = framework.IngressNginxDescribe("Configure OpenTracing", func() { assert.NotContains(ginkgo.GinkgoT(), log, "Unexpected failure reloading the backend", "reloading nginx after a configmap change") }) + ginkgo.It("should propagate the w3c header when configured with jaeger", func() { + host := "jaeger-w3c" + config := map[string]string{} + config[enableOpentracing] = "true" + config[jaegerCollectorHost] = "127.0.0.1" + config[jaegerPropagationFormat] = "w3c" + f.SetNginxConfigMapData(config) + + framework.Sleep(10 * time.Second) + log, err := f.NginxLogs() + assert.Nil(ginkgo.GinkgoT(), err, "obtaining nginx logs") + assert.NotContains(ginkgo.GinkgoT(), log, "Unexpected failure reloading the backend", "reloading nginx after a configmap change") + + ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil) + f.EnsureIngress(ing) + + f.WaitForNginxServer(host, + func(server string) bool { + return strings.Contains(server, fmt.Sprintf("server_name %s ;", host)) + }) + + f.HTTPTestClient(). + GET("/"). + WithHeader("Host", host). + Expect(). + Status(http.StatusOK). + Body(). + Match("traceparent=[0-9a-f]{2}-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}") + }) + /* ginkgo.It("should enable opentracing using jaeger with an HTTP endpoint", func() { config := map[string]string{}