parent
dd2a1bfc82
commit
b7814204a4
4 changed files with 17 additions and 9 deletions
|
@ -56,6 +56,8 @@ You can run Zipkin on a Docker host like this:
|
||||||
docker run -d -p 9411:9411 openzipkin/zipkin
|
docker run -d -p 9411:9411 openzipkin/zipkin
|
||||||
```
|
```
|
||||||
|
|
||||||
|
:warning: The zipkin provider does not support the v1 API since coredns 1.7.1
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
Use an alternative Zipkin address:
|
Use an alternative Zipkin address:
|
||||||
|
|
|
@ -35,7 +35,9 @@ func traceParse(c *caddy.Controller) (*trace, error) {
|
||||||
)
|
)
|
||||||
|
|
||||||
cfg := dnsserver.GetConfig(c)
|
cfg := dnsserver.GetConfig(c)
|
||||||
tr.serviceEndpoint = cfg.ListenHosts[0] + ":" + cfg.Port
|
if cfg.ListenHosts[0] != "" {
|
||||||
|
tr.serviceEndpoint = cfg.ListenHosts[0] + ":" + cfg.Port
|
||||||
|
}
|
||||||
|
|
||||||
for c.Next() { // trace
|
for c.Next() { // trace
|
||||||
var err error
|
var err error
|
||||||
|
@ -115,7 +117,7 @@ func normalizeEndpoint(epType, ep string) (string, string, error) {
|
||||||
|
|
||||||
if epType == "zipkin" {
|
if epType == "zipkin" {
|
||||||
if !strings.Contains(ep, "http") {
|
if !strings.Contains(ep, "http") {
|
||||||
ep = "http://" + ep + "/api/v1/spans"
|
ep = "http://" + ep + "/api/v2/spans"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,17 +16,17 @@ func TestTraceParse(t *testing.T) {
|
||||||
clientServer bool
|
clientServer bool
|
||||||
}{
|
}{
|
||||||
// oks
|
// oks
|
||||||
{`trace`, false, "http://localhost:9411/api/v1/spans", 1, `coredns`, false},
|
{`trace`, false, "http://localhost:9411/api/v2/spans", 1, `coredns`, false},
|
||||||
{`trace localhost:1234`, false, "http://localhost:1234/api/v1/spans", 1, `coredns`, false},
|
{`trace localhost:1234`, false, "http://localhost:1234/api/v2/spans", 1, `coredns`, false},
|
||||||
{`trace http://localhost:1234/somewhere/else`, false, "http://localhost:1234/somewhere/else", 1, `coredns`, false},
|
{`trace http://localhost:1234/somewhere/else`, false, "http://localhost:1234/somewhere/else", 1, `coredns`, false},
|
||||||
{`trace zipkin localhost:1234`, false, "http://localhost:1234/api/v1/spans", 1, `coredns`, false},
|
{`trace zipkin localhost:1234`, false, "http://localhost:1234/api/v2/spans", 1, `coredns`, false},
|
||||||
{`trace datadog localhost`, false, "localhost", 1, `coredns`, false},
|
{`trace datadog localhost`, false, "localhost", 1, `coredns`, false},
|
||||||
{`trace datadog http://localhost:8127`, false, "http://localhost:8127", 1, `coredns`, false},
|
{`trace datadog http://localhost:8127`, false, "http://localhost:8127", 1, `coredns`, false},
|
||||||
{"trace datadog localhost {\n datadog_analytics_rate 0.1\n}", false, "localhost", 1, `coredns`, false},
|
{"trace datadog localhost {\n datadog_analytics_rate 0.1\n}", false, "localhost", 1, `coredns`, false},
|
||||||
{"trace {\n every 100\n}", false, "http://localhost:9411/api/v1/spans", 100, `coredns`, false},
|
{"trace {\n every 100\n}", false, "http://localhost:9411/api/v2/spans", 100, `coredns`, false},
|
||||||
{"trace {\n every 100\n service foobar\nclient_server\n}", false, "http://localhost:9411/api/v1/spans", 100, `foobar`, true},
|
{"trace {\n every 100\n service foobar\nclient_server\n}", false, "http://localhost:9411/api/v2/spans", 100, `foobar`, true},
|
||||||
{"trace {\n every 2\n client_server true\n}", false, "http://localhost:9411/api/v1/spans", 2, `coredns`, true},
|
{"trace {\n every 2\n client_server true\n}", false, "http://localhost:9411/api/v2/spans", 2, `coredns`, true},
|
||||||
{"trace {\n client_server false\n}", false, "http://localhost:9411/api/v1/spans", 1, `coredns`, false},
|
{"trace {\n client_server false\n}", false, "http://localhost:9411/api/v2/spans", 1, `coredns`, false},
|
||||||
// fails
|
// fails
|
||||||
{`trace footype localhost:4321`, true, "", 1, "", false},
|
{`trace footype localhost:4321`, true, "", 1, "", false},
|
||||||
{"trace {\n every 2\n client_server junk\n}", true, "", 1, "", false},
|
{"trace {\n every 2\n client_server junk\n}", true, "", 1, "", false},
|
||||||
|
@ -47,6 +47,9 @@ func TestTraceParse(t *testing.T) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if "" != m.serviceEndpoint {
|
||||||
|
t.Errorf("Test %v: Expected serviceEndpoint to be '' but found: %s", i, m.serviceEndpoint)
|
||||||
|
}
|
||||||
if test.endpoint != m.Endpoint {
|
if test.endpoint != m.Endpoint {
|
||||||
t.Errorf("Test %v: Expected endpoint %s but found: %s", i, test.endpoint, m.Endpoint)
|
t.Errorf("Test %v: Expected endpoint %s but found: %s", i, test.endpoint, m.Endpoint)
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,7 @@ func (t *trace) setupZipkin() error {
|
||||||
tracer, err := zipkin.NewTracer(
|
tracer, err := zipkin.NewTracer(
|
||||||
reporter,
|
reporter,
|
||||||
zipkin.WithLocalEndpoint(recorder),
|
zipkin.WithLocalEndpoint(recorder),
|
||||||
|
zipkin.WithSharedSpans(t.clientServer),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Reference in a new issue