mirror of
https://github.com/coredns/coredns.git
synced 2026-10-17 07:45:42 -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:
@@ -1,9 +1,9 @@
|
||||
.\" Generated by Mmark Markdown Processer - mmark.miek.nl
|
||||
.\" Generated by Mmark Markdown Processor - mmark.miek.nl
|
||||
.TH "COREDNS-TRACE" 7 "October 2026" "CoreDNS" "CoreDNS Plugins"
|
||||
|
||||
.SH "NAME"
|
||||
.PP
|
||||
\fItrace\fP - enables OpenTracing-based tracing of DNS requests as they go through the plugin chain.
|
||||
\fItrace\fP \- enables OpenTracing\-based tracing of DNS requests as they go through the plugin chain.
|
||||
|
||||
.SH "DESCRIPTION"
|
||||
.PP
|
||||
@@ -24,11 +24,12 @@ trace [ENDPOINT\-TYPE] [ENDPOINT]
|
||||
.RE
|
||||
|
||||
.IP \(bu 4
|
||||
\fBENDPOINT-TYPE\fP is the type of tracing destination. Currently only \fB\fCzipkin\fR and \fB\fCdatadog\fR are supported.
|
||||
\fBENDPOINT\-TYPE\fP is the type of tracing destination. Currently only \fB\fCzipkin\fR and \fB\fCdatadog\fR are supported.
|
||||
Defaults to \fB\fCzipkin\fR.
|
||||
.IP \(bu 4
|
||||
\fBENDPOINT\fP is the tracing destination, and defaults to \fB\fClocalhost:9411\fR. For Zipkin, if
|
||||
\fBENDPOINT\fP does not begin with \fB\fChttp\fR, then it will be transformed to \fB\fChttp://ENDPOINT/api/v2/spans\fR.
|
||||
\fBENDPOINT\fP does not begin with \fB\fChttp://\fR or \fB\fChttps://\fR (case\-insensitive), then it will be transformed to
|
||||
\fB\fChttp://ENDPOINT/api/v2/spans\fR.
|
||||
|
||||
|
||||
.PP
|
||||
@@ -66,7 +67,7 @@ Default is \fB\fCcoredns\fR.
|
||||
\fB\fCdatadog_analytics_rate\fR \fBRATE\fP will enable trace analytics
|
||||
\[la]https://docs.datadoghq.com/tracing/app_analytics\[ra] on the traces sent
|
||||
from \fI0\fP to \fI1\fP, \fI1\fP being every trace sent will be analyzed. This is a datadog only feature
|
||||
(\fBENDPOINT-TYPE\fP needs to be \fB\fCdatadog\fR)
|
||||
(\fBENDPOINT\-TYPE\fP needs to be \fB\fCdatadog\fR)
|
||||
.IP \(bu 4
|
||||
\fB\fCzipkin_max_backlog_size\fR configures the maximum backlog size for Zipkin HTTP reporter. When batch size reaches this threshold,
|
||||
spans from the beginning of the batch will be disposed. Default is 1000 backlog size.
|
||||
|
||||
@@ -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