| 
									
										
										
										
											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
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | With *trace* you enable OpenTracing of how a request flows through CoreDNS. | 
					
						
							| 
									
										
										
										
											2020-07-23 00:40:17 -07:00
										 |  |  | Enable *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 | 
					
						
							|  |  |  |   ENDPOINT does not begin with `http`, then it will be transformed to `http://ENDPOINT/api/v1/spans`. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | With this form, all queries will be traced. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Additional features can be enabled with this syntax: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ~~~ | 
					
						
							|  |  |  | trace [ENDPOINT-TYPE] [ENDPOINT] { | 
					
						
							|  |  |  | 	every AMOUNT | 
					
						
							|  |  |  | 	service NAME | 
					
						
							|  |  |  | 	client_server | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ~~~ | 
					
						
							| 
									
										
										
										
											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. | 
					
						
							| 
									
										
										
										
											2017-01-23 15:40:47 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-16 12:13:18 -05:00
										 |  |  | ## Zipkin
 | 
					
						
							|  |  |  | 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 | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## 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: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ~~~ | 
					
						
							|  |  |  | trace datadog localhost:8125 | 
					
						
							|  |  |  | ~~~ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							|  |  |  | ## Also See
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | See the *debug* plugin for more information about debug logging. |