Make Zipkin trace rate configurable
This commit is contained in:
parent
51650c1412
commit
32f7fb8bff
6 changed files with 24 additions and 10 deletions
|
@ -208,6 +208,7 @@ func NewTraefikDefaultPointersConfiguration() *TraefikConfiguration {
|
||||||
SameSpan: false,
|
SameSpan: false,
|
||||||
ID128Bit: true,
|
ID128Bit: true,
|
||||||
Debug: false,
|
Debug: false,
|
||||||
|
SampleRate: 1.0,
|
||||||
},
|
},
|
||||||
DataDog: &datadog.Config{
|
DataDog: &datadog.Config{
|
||||||
LocalAgentHostPort: "localhost:8126",
|
LocalAgentHostPort: "localhost:8126",
|
||||||
|
|
|
@ -206,6 +206,7 @@ func (gc *GlobalConfiguration) initTracing() {
|
||||||
SameSpan: false,
|
SameSpan: false,
|
||||||
ID128Bit: true,
|
ID128Bit: true,
|
||||||
Debug: false,
|
Debug: false,
|
||||||
|
SampleRate: 1.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if gc.Tracing.Jaeger != nil {
|
if gc.Tracing.Jaeger != nil {
|
||||||
|
|
|
@ -120,6 +120,7 @@ func TestSetEffectiveConfigurationTracing(t *testing.T) {
|
||||||
SameSpan: false,
|
SameSpan: false,
|
||||||
ID128Bit: true,
|
ID128Bit: true,
|
||||||
Debug: false,
|
Debug: false,
|
||||||
|
SampleRate: 1.0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -138,6 +139,7 @@ func TestSetEffectiveConfigurationTracing(t *testing.T) {
|
||||||
SameSpan: true,
|
SameSpan: true,
|
||||||
ID128Bit: true,
|
ID128Bit: true,
|
||||||
Debug: true,
|
Debug: true,
|
||||||
|
SampleRate: 0.02,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: &tracing.Tracing{
|
expected: &tracing.Tracing{
|
||||||
|
@ -148,6 +150,7 @@ func TestSetEffectiveConfigurationTracing(t *testing.T) {
|
||||||
SameSpan: true,
|
SameSpan: true,
|
||||||
ID128Bit: true,
|
ID128Bit: true,
|
||||||
Debug: true,
|
Debug: true,
|
||||||
|
SampleRate: 0.02,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -100,7 +100,7 @@ Træfik supports three tracing backends: Jaeger, Zipkin and DataDog.
|
||||||
spanNameLimit = 150
|
spanNameLimit = 150
|
||||||
|
|
||||||
[tracing.zipkin]
|
[tracing.zipkin]
|
||||||
# Zipking HTTP endpoint used to send data
|
# Zipkin HTTP endpoint used to send data
|
||||||
#
|
#
|
||||||
# Default: "http://localhost:9411/api/v1/spans"
|
# Default: "http://localhost:9411/api/v1/spans"
|
||||||
#
|
#
|
||||||
|
@ -112,17 +112,23 @@ Træfik supports three tracing backends: Jaeger, Zipkin and DataDog.
|
||||||
#
|
#
|
||||||
debug = false
|
debug = false
|
||||||
|
|
||||||
# Use ZipKin SameSpan RPC style traces
|
# Use Zipkin SameSpan RPC style traces
|
||||||
#
|
#
|
||||||
# Default: false
|
# Default: false
|
||||||
#
|
#
|
||||||
sameSpan = false
|
sameSpan = false
|
||||||
|
|
||||||
# Use ZipKin 128 bit root span IDs
|
# Use Zipkin 128 bit root span IDs
|
||||||
#
|
#
|
||||||
# Default: true
|
# Default: true
|
||||||
#
|
#
|
||||||
id128Bit = true
|
id128Bit = true
|
||||||
|
|
||||||
|
# The rate between 0.0 and 1.0 of requests to trace.
|
||||||
|
#
|
||||||
|
# Default: 1.0
|
||||||
|
#
|
||||||
|
sampleRate = 0.2
|
||||||
```
|
```
|
||||||
|
|
||||||
## DataDog
|
## DataDog
|
||||||
|
|
|
@ -85,7 +85,7 @@ func (s *TracingSuite) TestZipkinRateLimit(c *check.C) {
|
||||||
err = try.GetRequest("http://127.0.0.1:8000/ratelimit", 500*time.Millisecond, try.StatusCodeIs(http.StatusTooManyRequests))
|
err = try.GetRequest("http://127.0.0.1:8000/ratelimit", 500*time.Millisecond, try.StatusCodeIs(http.StatusTooManyRequests))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
err = try.GetRequest("http://"+s.ZipkinIP+":9411/api/v2/spans?serviceName=tracing", 10*time.Second, try.BodyContains("forward frontend1/backend1", "rate limit"))
|
err = try.GetRequest("http://"+s.ZipkinIP+":9411/api/v2/spans?serviceName=tracing", 20*time.Second, try.BodyContains("forward frontend1/backend1", "rate limit"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ func (s *TracingSuite) TestZipkinRetry(c *check.C) {
|
||||||
err = try.GetRequest("http://127.0.0.1:8000/retry", 500*time.Millisecond, try.StatusCodeIs(http.StatusBadGateway))
|
err = try.GetRequest("http://127.0.0.1:8000/retry", 500*time.Millisecond, try.StatusCodeIs(http.StatusBadGateway))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
err = try.GetRequest("http://"+s.ZipkinIP+":9411/api/v2/spans?serviceName=tracing", 10*time.Second, try.BodyContains("forward frontend2/backend2", "retry"))
|
err = try.GetRequest("http://"+s.ZipkinIP+":9411/api/v2/spans?serviceName=tracing", 20*time.Second, try.BodyContains("forward frontend2/backend2", "retry"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,6 +132,6 @@ func (s *TracingSuite) TestZipkinAuth(c *check.C) {
|
||||||
err = try.GetRequest("http://127.0.0.1:8000/auth", 500*time.Millisecond, try.StatusCodeIs(http.StatusUnauthorized))
|
err = try.GetRequest("http://127.0.0.1:8000/auth", 500*time.Millisecond, try.StatusCodeIs(http.StatusUnauthorized))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
err = try.GetRequest("http://"+s.ZipkinIP+":9411/api/v2/spans?serviceName=tracing", 10*time.Second, try.BodyContains("entrypoint http", "auth basic"))
|
err = try.GetRequest("http://"+s.ZipkinIP+":9411/api/v2/spans?serviceName=tracing", 20*time.Second, try.BodyContains("entrypoint http", "auth basic"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package zipkin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/containous/traefik/log"
|
"github.com/containous/traefik/log"
|
||||||
"github.com/opentracing/opentracing-go"
|
"github.com/opentracing/opentracing-go"
|
||||||
|
@ -14,9 +15,10 @@ const Name = "zipkin"
|
||||||
// Config provides configuration settings for a zipkin tracer
|
// Config provides configuration settings for a zipkin tracer
|
||||||
type Config struct {
|
type Config struct {
|
||||||
HTTPEndpoint string `description:"HTTP Endpoint to report traces to." export:"false"`
|
HTTPEndpoint string `description:"HTTP Endpoint to report traces to." export:"false"`
|
||||||
SameSpan bool `description:"Use ZipKin SameSpan RPC style traces." export:"true"`
|
SameSpan bool `description:"Use Zipkin SameSpan RPC style traces." export:"true"`
|
||||||
ID128Bit bool `description:"Use ZipKin 128 bit root span IDs." export:"true"`
|
ID128Bit bool `description:"Use Zipkin 128 bit root span IDs." export:"true"`
|
||||||
Debug bool `description:"Enable Zipkin debug." export:"true"`
|
Debug bool `description:"Enable Zipkin debug." export:"true"`
|
||||||
|
SampleRate float64 `description:"The rate between 0.0 and 1.0 of requests to trace." export:"true"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup sets up the tracer
|
// Setup sets up the tracer
|
||||||
|
@ -31,6 +33,7 @@ func (c *Config) Setup(serviceName string) (opentracing.Tracer, io.Closer, error
|
||||||
zipkin.ClientServerSameSpan(c.SameSpan),
|
zipkin.ClientServerSameSpan(c.SameSpan),
|
||||||
zipkin.TraceID128Bit(c.ID128Bit),
|
zipkin.TraceID128Bit(c.ID128Bit),
|
||||||
zipkin.DebugMode(c.Debug),
|
zipkin.DebugMode(c.Debug),
|
||||||
|
zipkin.WithSampler(zipkin.NewBoundarySampler(c.SampleRate, time.Now().Unix())),
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue