Skip to content

Commit

Permalink
add support for the jaeger propagation format
Browse files Browse the repository at this point in the history
adding default, testing w3c traceparent is propagated
  • Loading branch information
Matthew Silverman committed Mar 26, 2021
1 parent 03cf9cf commit 71c8ef1
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/user-guide/nginx-configuration/configmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/user-guide/third-party-addons/opentracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions internal/ingress/controller/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -867,6 +870,7 @@ func NewDefault() Configuration {
ZipkinServiceName: "nginx",
ZipkinSampleRate: 1.0,
JaegerCollectorPort: 6831,
JaegerPropagationFormat: "jaeger",
JaegerServiceName: "nginx",
JaegerSamplerType: "const",
JaegerSamplerParam: "1",
Expand Down
1 change: 1 addition & 0 deletions internal/ingress/controller/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,7 @@ const zipkinTmpl = `{

const jaegerTmpl = `{
"service_name": "{{ .JaegerServiceName }}",
"propagation_format": "{{ .JaegerPropagationFormat }}",
"sampler": {
"type": "{{ .JaegerSamplerType }}",
"param": {{ .JaegerSamplerParam }},
Expand Down
37 changes: 35 additions & 2 deletions test/e2e/settings/opentracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package settings

import (
"fmt"
"net/http"
"strings"
"time"

Expand All @@ -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"
Expand Down Expand Up @@ -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{}
Expand Down

0 comments on commit 71c8ef1

Please sign in to comment.