2017-01-23 15:40:47 -05:00
# trace
2018-01-04 12:53:07 +00:00
## Name
*trace* - enables OpenTracing-based tracing of DNS requests as they go through the plugin chain.
## Description
2020-11-19 12:19:50 +01:00
With *trace* you enable OpenTracing of how a request flows through CoreDNS. Enable the *debug*
plugin to get logs from the trace plugin.
2017-01-23 15:40:47 -05:00
## Syntax
2017-02-16 12:13:18 -05:00
The simplest form is just:
2017-01-23 15:40:47 -05:00
~~~
trace [ENDPOINT-TYPE] [ENDPOINT]
~~~
2018-03-09 16:08:57 -04:00
* **ENDPOINT-TYPE** is the type of tracing destination. Currently only `zipkin` and `datadog` are supported.
Defaults to `zipkin` .
2017-02-16 12:13:18 -05:00
* **ENDPOINT** is the tracing destination, and defaults to `localhost:9411` . For Zipkin, if
2020-11-19 12:19:50 +01:00
**ENDPOINT** does not begin with `http` , then it will be transformed to `http://ENDPOINT/api/v1/spans` .
2017-02-16 12:13:18 -05:00
With this form, all queries will be traced.
Additional features can be enabled with this syntax:
~~~
trace [ENDPOINT-TYPE] [ENDPOINT] {
2020-10-12 21:30:55 +02:00
every AMOUNT
service NAME
client_server
datadog_analytics_rate RATE
2022-07-08 13:20:19 +02:00
zipkin_max_backlog_size SIZE
zipkin_max_batch_size SIZE
zipkin_max_batch_interval DURATION
2017-02-16 12:13:18 -05:00
}
~~~
2017-01-23 15:40:47 -05:00
2017-02-16 12:13:18 -05:00
* `every` **AMOUNT** will only trace one query of each AMOUNT queries. For example, to trace 1 in every
100 queries, use AMOUNT of 100. The default is 1.
* `service` **NAME** allows you to specify the service name reported to the tracing server.
Default is `coredns` .
* `client_server` will enable the `ClientServerSameSpan` OpenTracing feature.
2020-10-12 21:30:55 +02:00
* `datadog_analytics_rate` **RATE** will enable [trace analytics ](https://docs.datadoghq.com/tracing/app_analytics ) on the traces sent
2020-11-19 12:19:50 +01:00
from *0* to *1* , *1* being every trace sent will be analyzed. This is a datadog only feature
(**ENDPOINT-TYPE** needs to be `datadog` )
2022-07-08 13:20:19 +02:00
* `zipkin_max_backlog_size` 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.
* `zipkin_max_batch_size` configures the maximum batch size for Zipkin HTTP reporter, after which a collect will be triggered. The default batch size is 100 traces.
* `zipkin_max_batch_interval` configures the maximum duration we will buffer traces before emitting them to the collector using Zipkin HTTP reporter.
The default batch interval is 1 second.
2017-01-23 15:40:47 -05:00
2017-02-16 12:13:18 -05:00
## Zipkin
2020-11-19 12:19:50 +01:00
2017-02-16 12:13:18 -05:00
You can run Zipkin on a Docker host like this:
2017-01-23 15:40:47 -05:00
```
docker run -d -p 9411:9411 openzipkin/zipkin
```
2020-11-19 12:19:50 +01:00
Note the zipkin provider does not support the v1 API since coredns 1.7.1.
2020-11-10 20:03:14 +01:00
2017-01-23 15:40:47 -05:00
## Examples
Use an alternative Zipkin address:
~~~
trace tracinghost:9253
~~~
or
2017-09-15 09:56:05 +01:00
~~~ corefile
. {
trace zipkin tracinghost:9253
}
2017-01-23 15:40:47 -05:00
~~~
If for some reason you are using an API reverse proxy or something and need to remap
the standard Zipkin URL you can do something like:
~~~
trace http://tracinghost:9411/zipkin/api/v1/spans
~~~
2017-02-16 12:13:18 -05:00
2018-03-09 16:08:57 -04:00
Using DataDog:
~~~
2020-12-11 13:07:25 -08:00
trace datadog localhost:8126
2018-03-09 16:08:57 -04:00
~~~
2017-02-16 12:13:18 -05:00
Trace one query every 10000 queries, rename the service, and enable same span:
~~~
trace tracinghost:9411 {
every 10000
service dnsproxy
client_server
}
~~~
2020-07-23 00:40:17 -07:00
2021-07-14 09:21:41 +02:00
## Metadata
The trace plugin will publish the following metadata, if the *metadata*
plugin is also enabled:
2021-07-20 10:28:21 +00:00
* `trace/traceid` : identifier of (zipkin/datadog) trace of processed request
2021-07-14 09:21:41 +02:00
2020-10-28 18:56:35 +01:00
## See Also
2020-07-23 00:40:17 -07:00
See the *debug* plugin for more information about debug logging.