mirror of
https://github.com/coredns/coredns.git
synced 2026-10-16 15:25:47 -04:00
plugin/trace: recognize Zipkin URL schemes by prefix (#8625)
* plugin/trace: recognize Zipkin URL schemes by prefix Signed-off-by: xinjun.jiang <xinjun.jiang@daocloud.io> * plugin/trace: compare HTTP schemes case insensitively Signed-off-by: xinjun.jiang <xinjun.jiang@daocloud.io> --------- Signed-off-by: xinjun.jiang <xinjun.jiang@daocloud.io>
This commit is contained in:
@@ -20,7 +20,8 @@ trace [ENDPOINT-TYPE] [ENDPOINT]
|
||||
* **ENDPOINT-TYPE** is the type of tracing destination. Currently only `zipkin` and `datadog` are supported.
|
||||
Defaults to `zipkin`.
|
||||
* **ENDPOINT** is the tracing destination, and defaults to `localhost:9411`. For Zipkin, if
|
||||
**ENDPOINT** does not begin with `http`, then it will be transformed to `http://ENDPOINT/api/v2/spans`.
|
||||
**ENDPOINT** does not begin with `http://` or `https://` (case-insensitive), then it will be transformed to
|
||||
`http://ENDPOINT/api/v2/spans`.
|
||||
|
||||
With this form, all queries will be traced.
|
||||
|
||||
|
||||
@@ -148,7 +148,8 @@ func normalizeEndpoint(epType, ep string) (string, string, error) {
|
||||
}
|
||||
|
||||
if epType == "zipkin" {
|
||||
if !strings.Contains(ep, "http") {
|
||||
lowerEp := strings.ToLower(ep)
|
||||
if !strings.HasPrefix(lowerEp, "http://") && !strings.HasPrefix(lowerEp, "https://") {
|
||||
ep = "http://" + ep + "/api/v2/spans"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,14 @@ func TestTraceParse(t *testing.T) {
|
||||
// oks
|
||||
{`trace`, false, "http://localhost:9411/api/v2/spans", 1, `coredns`, false, 0, 0, 0},
|
||||
{`trace localhost:1234`, false, "http://localhost:1234/api/v2/spans", 1, `coredns`, false, 0, 0, 0},
|
||||
{`trace zipkin-http.monitoring:9411`, false, "http://zipkin-http.monitoring:9411/api/v2/spans", 1, `coredns`, false, 0, 0, 0},
|
||||
{`trace zipkin http-collector:9411`, false, "http://http-collector:9411/api/v2/spans", 1, `coredns`, false, 0, 0, 0},
|
||||
{`trace zipkin myhttpscollector:9411`, false, "http://myhttpscollector:9411/api/v2/spans", 1, `coredns`, false, 0, 0, 0},
|
||||
{`trace zipkin https://zipkin-http.monitoring:9411/custom/spans`, false, "https://zipkin-http.monitoring:9411/custom/spans", 1, `coredns`, false, 0, 0, 0},
|
||||
{`trace HTTP://collector:9411/api/v2/spans`, false, "HTTP://collector:9411/api/v2/spans", 1, `coredns`, false, 0, 0, 0},
|
||||
{`trace zipkin HTTPS://collector:9411/api/v2/spans`, false, "HTTPS://collector:9411/api/v2/spans", 1, `coredns`, false, 0, 0, 0},
|
||||
{`trace zipkin HtTpS://collector:9411/Custom/Spans?Tenant=Blue`, false, "HtTpS://collector:9411/Custom/Spans?Tenant=Blue", 1, `coredns`, false, 0, 0, 0},
|
||||
{`trace zipkin httpS://collector:9411/Custom/Spans?Tenant=Blue`, false, "httpS://collector:9411/Custom/Spans?Tenant=Blue", 1, `coredns`, false, 0, 0, 0},
|
||||
{`trace http://localhost:1234/somewhere/else`, false, "http://localhost:1234/somewhere/else", 1, `coredns`, false, 0, 0, 0},
|
||||
{`trace zipkin localhost:1234`, false, "http://localhost:1234/api/v2/spans", 1, `coredns`, false, 0, 0, 0},
|
||||
{`trace datadog localhost`, false, "localhost", 1, `coredns`, false, 0, 0, 0},
|
||||
|
||||
Reference in New Issue
Block a user