Improve tracing
This commit is contained in:
parent
4245096be4
commit
84d7c65039
23 changed files with 924 additions and 411 deletions
|
@ -1,234 +0,0 @@
|
||||||
# Tracing
|
|
||||||
|
|
||||||
Visualize the Requests Flow
|
|
||||||
{: .subtitle }
|
|
||||||
|
|
||||||
The tracing system allows developers to visualize call flows in their infrastructure.
|
|
||||||
|
|
||||||
Traefik uses OpenTracing, an open standard designed for distributed tracing.
|
|
||||||
|
|
||||||
Traefik supports four tracing backends: Jaeger, Zipkin, DataDog, and Instana.
|
|
||||||
|
|
||||||
## Configuration Reference
|
|
||||||
|
|
||||||
??? example "With Jaeger"
|
|
||||||
|
|
||||||
```toml
|
|
||||||
# Tracing definition
|
|
||||||
[tracing]
|
|
||||||
# Backend name used to send tracing data
|
|
||||||
#
|
|
||||||
# Default: "jaeger"
|
|
||||||
#
|
|
||||||
backend = "jaeger"
|
|
||||||
|
|
||||||
# Service name used in Jaeger backend
|
|
||||||
#
|
|
||||||
# Default: "traefik"
|
|
||||||
#
|
|
||||||
serviceName = "traefik"
|
|
||||||
|
|
||||||
# Span name limit allows for name truncation in case of very long Frontend/Backend names
|
|
||||||
# This can prevent certain tracing providers to drop traces that exceed their length limits
|
|
||||||
#
|
|
||||||
# Default: 0 - no truncation will occur
|
|
||||||
#
|
|
||||||
spanNameLimit = 0
|
|
||||||
|
|
||||||
[tracing.jaeger]
|
|
||||||
# Sampling Server URL is the address of jaeger-agent's HTTP sampling server
|
|
||||||
#
|
|
||||||
# Default: "http://localhost:5778/sampling"
|
|
||||||
#
|
|
||||||
samplingServerURL = "http://localhost:5778/sampling"
|
|
||||||
|
|
||||||
# Sampling Type specifies the type of the sampler: const, probabilistic, rateLimiting
|
|
||||||
#
|
|
||||||
# Default: "const"
|
|
||||||
#
|
|
||||||
samplingType = "const"
|
|
||||||
|
|
||||||
# Sampling Param is a value passed to the sampler.
|
|
||||||
# Valid values for Param field are:
|
|
||||||
# - for "const" sampler, 0 or 1 for always false/true respectively
|
|
||||||
# - for "probabilistic" sampler, a probability between 0 and 1
|
|
||||||
# - for "rateLimiting" sampler, the number of spans per second
|
|
||||||
#
|
|
||||||
# Default: 1.0
|
|
||||||
#
|
|
||||||
samplingParam = 1.0
|
|
||||||
|
|
||||||
# Local Agent Host Port instructs reporter to send spans to jaeger-agent at this address
|
|
||||||
#
|
|
||||||
# Default: "127.0.0.1:6831"
|
|
||||||
#
|
|
||||||
localAgentHostPort = "127.0.0.1:6831"
|
|
||||||
|
|
||||||
# Generate 128-bit trace IDs, compatible with OpenCensus
|
|
||||||
#
|
|
||||||
# Default: false
|
|
||||||
gen128Bit = true
|
|
||||||
|
|
||||||
# Set the propagation header type. This can be either:
|
|
||||||
# - "jaeger", jaeger's default trace header.
|
|
||||||
# - "b3", compatible with OpenZipkin
|
|
||||||
#
|
|
||||||
# Default: "jaeger"
|
|
||||||
propagation = "jaeger"
|
|
||||||
|
|
||||||
# Trace Context Header Name is the http header name used to propagate tracing context.
|
|
||||||
# This must be in lower-case to avoid mismatches when decoding incoming headers.
|
|
||||||
#
|
|
||||||
# Default: "uber-trace-id"
|
|
||||||
#
|
|
||||||
traceContextHeaderName = "uber-trace-id"
|
|
||||||
```
|
|
||||||
|
|
||||||
!!! warning
|
|
||||||
Traefik is only able to send data over the compact thrift protocol to the [Jaeger agent](https://www.jaegertracing.io/docs/deployment/#agent).
|
|
||||||
|
|
||||||
??? example "With Zipkin"
|
|
||||||
|
|
||||||
```toml
|
|
||||||
# Tracing definition
|
|
||||||
[tracing]
|
|
||||||
# Backend name used to send tracing data
|
|
||||||
#
|
|
||||||
# Default: "jaeger"
|
|
||||||
#
|
|
||||||
backend = "zipkin"
|
|
||||||
|
|
||||||
# Service name used in Zipkin backend
|
|
||||||
#
|
|
||||||
# Default: "traefik"
|
|
||||||
#
|
|
||||||
serviceName = "traefik"
|
|
||||||
|
|
||||||
# Span name limit allows for name truncation in case of very long Frontend/Backend names
|
|
||||||
# This can prevent certain tracing providers to drop traces that exceed their length limits
|
|
||||||
#
|
|
||||||
# Default: 0 - no truncation will occur
|
|
||||||
#
|
|
||||||
spanNameLimit = 150
|
|
||||||
|
|
||||||
[tracing.zipkin]
|
|
||||||
# Zipkin HTTP endpoint used to send data
|
|
||||||
#
|
|
||||||
# Default: "http://localhost:9411/api/v1/spans"
|
|
||||||
#
|
|
||||||
httpEndpoint = "http://localhost:9411/api/v1/spans"
|
|
||||||
|
|
||||||
# Enable Zipkin debug
|
|
||||||
#
|
|
||||||
# Default: false
|
|
||||||
#
|
|
||||||
debug = false
|
|
||||||
|
|
||||||
# Use Zipkin SameSpan RPC style traces
|
|
||||||
#
|
|
||||||
# Default: false
|
|
||||||
#
|
|
||||||
sameSpan = false
|
|
||||||
|
|
||||||
# Use Zipkin 128 bit root span IDs
|
|
||||||
#
|
|
||||||
# Default: true
|
|
||||||
#
|
|
||||||
id128Bit = true
|
|
||||||
|
|
||||||
# The rate between 0.0 and 1.0 of requests to trace.
|
|
||||||
#
|
|
||||||
# Default: 1.0
|
|
||||||
#
|
|
||||||
sampleRate = 0.2
|
|
||||||
```
|
|
||||||
|
|
||||||
??? example "With DataDog"
|
|
||||||
|
|
||||||
```toml
|
|
||||||
# Tracing definition
|
|
||||||
[tracing]
|
|
||||||
# Backend name used to send tracing data
|
|
||||||
#
|
|
||||||
# Default: "jaeger"
|
|
||||||
#
|
|
||||||
backend = "datadog"
|
|
||||||
|
|
||||||
# Service name used in DataDog backend
|
|
||||||
#
|
|
||||||
# Default: "traefik"
|
|
||||||
#
|
|
||||||
serviceName = "traefik"
|
|
||||||
|
|
||||||
# Span name limit allows for name truncation in case of very long Frontend/Backend names
|
|
||||||
# This can prevent certain tracing providers to drop traces that exceed their length limits
|
|
||||||
#
|
|
||||||
# Default: 0 - no truncation will occur
|
|
||||||
#
|
|
||||||
spanNameLimit = 100
|
|
||||||
|
|
||||||
[tracing.datadog]
|
|
||||||
# Local Agent Host Port instructs reporter to send spans to datadog-tracing-agent at this address
|
|
||||||
#
|
|
||||||
# Default: "127.0.0.1:8126"
|
|
||||||
#
|
|
||||||
localAgentHostPort = "127.0.0.1:8126"
|
|
||||||
|
|
||||||
# Enable DataDog debug
|
|
||||||
#
|
|
||||||
# Default: false
|
|
||||||
#
|
|
||||||
debug = false
|
|
||||||
|
|
||||||
# Apply shared tag in a form of Key:Value to all the traces
|
|
||||||
#
|
|
||||||
# Default: ""
|
|
||||||
#
|
|
||||||
globalTag = ""
|
|
||||||
|
|
||||||
# Enable priority sampling. When using distributed tracing, this option must be enabled in order
|
|
||||||
# to get all the parts of a distributed trace sampled.
|
|
||||||
#
|
|
||||||
# Default: false
|
|
||||||
#
|
|
||||||
prioritySampling = false
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
??? example "With Instana"
|
|
||||||
|
|
||||||
```toml
|
|
||||||
# Tracing definition
|
|
||||||
[tracing]
|
|
||||||
# Backend name used to send tracing data
|
|
||||||
#
|
|
||||||
# Default: "jaeger"
|
|
||||||
#
|
|
||||||
backend = "instana"
|
|
||||||
# Service name used in Instana backend
|
|
||||||
#
|
|
||||||
# Default: "traefik"
|
|
||||||
#
|
|
||||||
serviceName = "traefik"
|
|
||||||
[tracing.instana]
|
|
||||||
# Local Agent Host instructs reporter to send spans to instana-agent at this address
|
|
||||||
#
|
|
||||||
# Default: "127.0.0.1"
|
|
||||||
#
|
|
||||||
localAgentHost = "127.0.0.1"
|
|
||||||
# Local Agent port instructs reporter to send spans to the instana-agent at this port
|
|
||||||
#
|
|
||||||
# Default: 42699
|
|
||||||
#
|
|
||||||
localAgentPort = 42699
|
|
||||||
# Set Instana tracer log level
|
|
||||||
#
|
|
||||||
# Default: info
|
|
||||||
# Valid values for logLevel field are:
|
|
||||||
# - error
|
|
||||||
# - warn
|
|
||||||
# - debug
|
|
||||||
# - info
|
|
||||||
#
|
|
||||||
logLevel = "info"
|
|
||||||
```
|
|
82
docs/content/observability/tracing/datadog.md
Normal file
82
docs/content/observability/tracing/datadog.md
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
# DataDog
|
||||||
|
|
||||||
|
To enable the DataDog:
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.datadog]
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.datadog
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `localAgentHostPort`
|
||||||
|
|
||||||
|
_Required, Default="127.0.0.1:8126"_
|
||||||
|
|
||||||
|
Local Agent Host Port instructs reporter to send spans to datadog-tracing-agent at this address.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.datadog]
|
||||||
|
localAgentHostPort = "127.0.0.1:8126"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.datadog.localAgentHostPort="127.0.0.1:8126"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `debug`
|
||||||
|
|
||||||
|
_Optional, Default=false_
|
||||||
|
|
||||||
|
Enable DataDog debug.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.datadog]
|
||||||
|
debug = true
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.datadog.debug=true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `globalTag`
|
||||||
|
|
||||||
|
_Optional, Default=empty_
|
||||||
|
|
||||||
|
Apply shared tag in a form of Key:Value to all the traces.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.datadog]
|
||||||
|
globalTag = "sample"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.datadog.globalTag="sample"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `prioritySampling`
|
||||||
|
|
||||||
|
_Optional, Default=false_
|
||||||
|
|
||||||
|
Enable priority sampling. When using distributed tracing,
|
||||||
|
this option must be enabled in order to get all the parts of a distributed trace sampled.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.datadog]
|
||||||
|
prioritySampling = true
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.datadog.prioritySampling=true
|
||||||
|
```
|
132
docs/content/observability/tracing/haystack.md
Normal file
132
docs/content/observability/tracing/haystack.md
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
# Haystack
|
||||||
|
|
||||||
|
To enable the Haystack:
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.haystack]
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.haystack
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `localAgentHost`
|
||||||
|
|
||||||
|
_Require, Default="127.0.0.1"_
|
||||||
|
|
||||||
|
Local Agent Host instructs reporter to send spans to haystack-agent at this address.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.haystack]
|
||||||
|
localAgentHost = "127.0.0.1"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.haystack.localAgentHost="127.0.0.1"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `localAgentPort`
|
||||||
|
|
||||||
|
_Require, Default=42699_
|
||||||
|
|
||||||
|
Local Agent port instructs reporter to send spans to the haystack-agent at this port.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.haystack]
|
||||||
|
localAgentPort = 42699
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.haystack.localAgentPort=42699
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `globalTag`
|
||||||
|
|
||||||
|
_Optional, Default=empty_
|
||||||
|
|
||||||
|
Apply shared tag in a form of Key:Value to all the traces.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.haystack]
|
||||||
|
globalTag = "sample:test"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.haystack.globalTag="sample:test"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `traceIDHeaderName`
|
||||||
|
|
||||||
|
_Optional, Default=empty_
|
||||||
|
|
||||||
|
Specifies the header name that will be used to store the trace ID.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.haystack]
|
||||||
|
traceIDHeaderName = "sample"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.haystack.traceIDHeaderName="sample"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `parentIDHeaderName`
|
||||||
|
|
||||||
|
_Optional, Default=empty_
|
||||||
|
|
||||||
|
Specifies the header name that will be used to store the span ID.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.haystack]
|
||||||
|
parentIDHeaderName = "sample"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.haystack.parentIDHeaderName="sample"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `spanIDHeaderName`
|
||||||
|
|
||||||
|
_Optional, Default=empty_
|
||||||
|
|
||||||
|
Apply shared tag in a form of Key:Value to all the traces.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.haystack]
|
||||||
|
spanIDHeaderName = "sample:test"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.haystack.spanIDHeaderName="sample:test"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `baggagePrefixHeaderName`
|
||||||
|
|
||||||
|
_Optional, Default=empty_
|
||||||
|
|
||||||
|
Specifies the header name prefix that will be used to store baggage items in a map.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.haystack]
|
||||||
|
baggagePrefixHeaderName = "sample"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.haystack.baggagePrefixHeaderName="sample"
|
||||||
|
```
|
71
docs/content/observability/tracing/instana.md
Normal file
71
docs/content/observability/tracing/instana.md
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
# Instana
|
||||||
|
|
||||||
|
To enable the Instana:
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.instana]
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.instana
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `localAgentHost`
|
||||||
|
|
||||||
|
_Require, Default="127.0.0.1"_
|
||||||
|
|
||||||
|
Local Agent Host instructs reporter to send spans to instana-agent at this address.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.instana]
|
||||||
|
localAgentHost = "127.0.0.1"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.instana.localAgentHost="127.0.0.1"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `localAgentPort`
|
||||||
|
|
||||||
|
_Require, Default=42699_
|
||||||
|
|
||||||
|
Local Agent port instructs reporter to send spans to the instana-agent at this port.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.instana]
|
||||||
|
localAgentPort = 42699
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.instana.localAgentPort=42699
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `logLevel`
|
||||||
|
|
||||||
|
_Require, Default="info"_
|
||||||
|
|
||||||
|
Set Instana tracer log level.
|
||||||
|
|
||||||
|
Valid values for logLevel field are:
|
||||||
|
|
||||||
|
- `error`
|
||||||
|
- `warn`
|
||||||
|
- `debug`
|
||||||
|
- `info`
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.instana]
|
||||||
|
logLevel = "info"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.instana.logLevel="info"
|
||||||
|
```
|
146
docs/content/observability/tracing/jaeger.md
Normal file
146
docs/content/observability/tracing/jaeger.md
Normal file
|
@ -0,0 +1,146 @@
|
||||||
|
# Jaeger
|
||||||
|
|
||||||
|
To enable the Jaeger:
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.jaeger]
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.jaeger
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! warning
|
||||||
|
Traefik is only able to send data over the compact thrift protocol to the [Jaeger agent](https://www.jaegertracing.io/docs/deployment/#agent).
|
||||||
|
|
||||||
|
#### `samplingServerURL`
|
||||||
|
|
||||||
|
_Required, Default="http://localhost:5778/sampling"_
|
||||||
|
|
||||||
|
Sampling Server URL is the address of jaeger-agent's HTTP sampling server.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.jaeger]
|
||||||
|
samplingServerURL = "http://localhost:5778/sampling"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.jaeger.samplingServerURL="http://localhost:5778/sampling"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `samplingType`
|
||||||
|
|
||||||
|
_Required, Default="const"_
|
||||||
|
|
||||||
|
Sampling Type specifies the type of the sampler: `const`, `probabilistic`, `rateLimiting`.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.jaeger]
|
||||||
|
samplingType = "const"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.jaeger.samplingType="const"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `samplingParam`
|
||||||
|
|
||||||
|
_Required, Default=1.0_
|
||||||
|
|
||||||
|
Sampling Param is a value passed to the sampler.
|
||||||
|
|
||||||
|
Valid values for Param field are:
|
||||||
|
|
||||||
|
- for `const` sampler, 0 or 1 for always false/true respectively
|
||||||
|
- for `probabilistic` sampler, a probability between 0 and 1
|
||||||
|
- for `rateLimiting` sampler, the number of spans per second
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.jaeger]
|
||||||
|
samplingParam = 1.0
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.jaeger.samplingParam="1.0"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `localAgentHostPort`
|
||||||
|
|
||||||
|
_Required, Default="127.0.0.1:6831"_
|
||||||
|
|
||||||
|
Local Agent Host Port instructs reporter to send spans to jaeger-agent at this address.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.jaeger]
|
||||||
|
localAgentHostPort = "127.0.0.1:6831"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.jaeger.localAgentHostPort="127.0.0.1:6831"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `gen128Bit`
|
||||||
|
|
||||||
|
_Optional, Default=false_
|
||||||
|
|
||||||
|
Generate 128-bit trace IDs, compatible with OpenCensus.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.jaeger]
|
||||||
|
gen128Bit = true
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.jaeger.gen128Bit
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `propagation`
|
||||||
|
|
||||||
|
_Required, Default="jaeger"_
|
||||||
|
|
||||||
|
Set the propagation header type.
|
||||||
|
This can be either:
|
||||||
|
|
||||||
|
- `jaeger`, jaeger's default trace header.
|
||||||
|
- `b3`, compatible with OpenZipkin
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.jaeger]
|
||||||
|
propagation = "jaeger"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.jaeger.propagation="jaeger"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `traceContextHeaderName`
|
||||||
|
|
||||||
|
_Required, Default="uber-trace-id"_
|
||||||
|
|
||||||
|
Trace Context Header Name is the http header name used to propagate tracing context.
|
||||||
|
This must be in lower-case to avoid mismatches when decoding incoming headers.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.jaeger]
|
||||||
|
traceContextHeaderName = "uber-trace-id"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.jaeger.traceContextHeaderName="uber-trace-id"
|
||||||
|
```
|
67
docs/content/observability/tracing/overview.md
Normal file
67
docs/content/observability/tracing/overview.md
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
# Tracing
|
||||||
|
|
||||||
|
Visualize the Requests Flow
|
||||||
|
{: .subtitle }
|
||||||
|
|
||||||
|
The tracing system allows developers to visualize call flows in their infrastructure.
|
||||||
|
|
||||||
|
Traefik uses OpenTracing, an open standard designed for distributed tracing.
|
||||||
|
|
||||||
|
Traefik supports five tracing backends:
|
||||||
|
|
||||||
|
- [Jaeger](./jaeger.md)
|
||||||
|
- [Zipkin](./zipkin.md)
|
||||||
|
- [DataDog](./datadog.md)
|
||||||
|
- [Instana](./instana.md)
|
||||||
|
- [Haystack](./haystack.md)
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
By default, Traefik uses Jaeger as tracing backend.
|
||||||
|
|
||||||
|
To enable the tracing:
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
```
|
||||||
|
|
||||||
|
### Common Options
|
||||||
|
|
||||||
|
#### `serviceName`
|
||||||
|
|
||||||
|
_Required, Default="traefik"_
|
||||||
|
|
||||||
|
Service name used in selected backend.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
serviceName = "traefik"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.serviceName="traefik"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `spanNameLimit`
|
||||||
|
|
||||||
|
_Required, Default=0_
|
||||||
|
|
||||||
|
Span name limit allows for name truncation in case of very long names.
|
||||||
|
This can prevent certain tracing providers to drop traces that exceed their length limits.
|
||||||
|
|
||||||
|
`0` means no truncation will occur.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
spanNameLimit = 150
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.spanNameLimit=150
|
||||||
|
```
|
98
docs/content/observability/tracing/zipkin.md
Normal file
98
docs/content/observability/tracing/zipkin.md
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
# Zipkin
|
||||||
|
|
||||||
|
To enable the Zipkin:
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.zipkin]
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.zipkin
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `httpEndpoint`
|
||||||
|
|
||||||
|
_Required, Default="http://localhost:9411/api/v1/spans"_
|
||||||
|
|
||||||
|
Zipkin HTTP endpoint used to send data.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.zipkin]
|
||||||
|
httpEndpoint = "http://localhost:9411/api/v1/spans"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.zipkin.httpEndpoint="http://localhost:9411/api/v1/spans"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `debug`
|
||||||
|
|
||||||
|
_Optional, Default=false_
|
||||||
|
|
||||||
|
Enable Zipkin debug.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.zipkin]
|
||||||
|
debug = true
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.zipkin.debug=true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `sameSpan`
|
||||||
|
|
||||||
|
_Optional, Default=false_
|
||||||
|
|
||||||
|
Use Zipkin SameSpan RPC style traces.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.zipkin]
|
||||||
|
sameSpan = true
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.zipkin.sameSpan=true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `id128Bit`
|
||||||
|
|
||||||
|
_Optional, Default=true_
|
||||||
|
|
||||||
|
Use Zipkin 128 bit root span IDs.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.zipkin]
|
||||||
|
id128Bit = false
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.zipkin.id128Bit=false
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `sampleRate`
|
||||||
|
|
||||||
|
_Required, Default=1.0_
|
||||||
|
|
||||||
|
The rate between 0.0 and 1.0 of requests to trace.
|
||||||
|
|
||||||
|
```toml tab="File"
|
||||||
|
[tracing]
|
||||||
|
[tracing.zipkin]
|
||||||
|
sampleRate = 0.2
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--tracing
|
||||||
|
--tracing.zipkin.sampleRate="0.2"
|
||||||
|
```
|
|
@ -490,9 +490,6 @@
|
||||||
--tracing (Default: "false")
|
--tracing (Default: "false")
|
||||||
OpenTracing configuration.
|
OpenTracing configuration.
|
||||||
|
|
||||||
--tracing.backend (Default: "jaeger")
|
|
||||||
Selects the tracking backend ('jaeger','zipkin','datadog','instana').
|
|
||||||
|
|
||||||
--tracing.datadog (Default: "false")
|
--tracing.datadog (Default: "false")
|
||||||
Settings for DataDog.
|
Settings for DataDog.
|
||||||
|
|
||||||
|
@ -526,7 +523,7 @@
|
||||||
Settings for Haystack.
|
Settings for Haystack.
|
||||||
|
|
||||||
--tracing.haystack.baggageprefixheadername (Default: "")
|
--tracing.haystack.baggageprefixheadername (Default: "")
|
||||||
specifies the header name prefix that will be used to store baggage items in a
|
Specifies the header name prefix that will be used to store baggage items in a
|
||||||
map.
|
map.
|
||||||
|
|
||||||
--tracing.haystack.globaltag (Default: "")
|
--tracing.haystack.globaltag (Default: "")
|
||||||
|
|
|
@ -474,9 +474,6 @@ Add cert file for self-signed certificate.
|
||||||
`TRAEFIK_TRACING`:
|
`TRAEFIK_TRACING`:
|
||||||
OpenTracing configuration. (Default: ```false```)
|
OpenTracing configuration. (Default: ```false```)
|
||||||
|
|
||||||
`TRAEFIK_TRACING_BACKEND`:
|
|
||||||
Selects the tracking backend ('jaeger','zipkin','datadog','instana'). (Default: ```jaeger```)
|
|
||||||
|
|
||||||
`TRAEFIK_TRACING_DATADOG`:
|
`TRAEFIK_TRACING_DATADOG`:
|
||||||
Settings for DataDog. (Default: ```false```)
|
Settings for DataDog. (Default: ```false```)
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,6 @@
|
||||||
name1 = "foobar"
|
name1 = "foobar"
|
||||||
|
|
||||||
[Tracing]
|
[Tracing]
|
||||||
Backend = "foobar"
|
|
||||||
ServiceName = "foobar"
|
ServiceName = "foobar"
|
||||||
SpanNameLimit = 42
|
SpanNameLimit = 42
|
||||||
|
|
||||||
|
@ -212,6 +211,14 @@
|
||||||
LocalAgentPort = 42
|
LocalAgentPort = 42
|
||||||
LogLevel = "foobar"
|
LogLevel = "foobar"
|
||||||
|
|
||||||
|
[Tracing.Haystack]
|
||||||
|
LocalAgentHost = "foobar"
|
||||||
|
LocalAgentPort = 42
|
||||||
|
GlobalTag = "foobar"
|
||||||
|
ParentIDHeaderName = "foobar"
|
||||||
|
SpanIDHeaderName = "foobar"
|
||||||
|
TraceIDHeaderName = "foobar"
|
||||||
|
|
||||||
[HostResolver]
|
[HostResolver]
|
||||||
CnameFlattening = true
|
CnameFlattening = true
|
||||||
ResolvConfig = "foobar"
|
ResolvConfig = "foobar"
|
||||||
|
|
|
@ -119,7 +119,13 @@ nav:
|
||||||
- 'Observability':
|
- 'Observability':
|
||||||
- 'Logs': 'observability/logs.md'
|
- 'Logs': 'observability/logs.md'
|
||||||
- 'Access Logs': 'observability/access-logs.md'
|
- 'Access Logs': 'observability/access-logs.md'
|
||||||
- 'Tracing': 'observability/tracing.md'
|
- 'Tracing':
|
||||||
|
- 'Overview': 'observability/tracing/overview.md'
|
||||||
|
- 'Jaeger': 'observability/tracing/jaeger.md'
|
||||||
|
- 'Zipkin': 'observability/tracing/zipkin.md'
|
||||||
|
- 'DataDog': 'observability/tracing/datadog.md'
|
||||||
|
- 'Instana': 'observability/tracing/instana.md'
|
||||||
|
- 'Haystack': 'observability/tracing/haystack.md'
|
||||||
- 'User Guides':
|
- 'User Guides':
|
||||||
- 'Kubernetes and Let''s Encrypt': 'user-guides/crd-acme/index.md'
|
- 'Kubernetes and Let''s Encrypt': 'user-guides/crd-acme/index.md'
|
||||||
- 'Marathon': 'user-guides/marathon.md'
|
- 'Marathon': 'user-guides/marathon.md'
|
||||||
|
|
|
@ -12,14 +12,12 @@ level = "DEBUG"
|
||||||
address = ":8000"
|
address = ":8000"
|
||||||
|
|
||||||
[tracing]
|
[tracing]
|
||||||
backend = "{{.TracingBackend}}"
|
|
||||||
servicename = "tracing"
|
servicename = "tracing"
|
||||||
[tracing.zipkin]
|
[tracing.jaeger]
|
||||||
httpEndpoint = "http://{{.ZipkinIP}}:9411/api/v1/spans"
|
samplingType = "const"
|
||||||
debug = true
|
samplingParam = 1.0
|
||||||
[tracing.jaeger]
|
samplingServerURL = "http://{{.IP}}:5778/sampling"
|
||||||
samplingType = "const"
|
localAgentHostPort = "{{.IP}}:6831"
|
||||||
samplingParam = 1.0
|
|
||||||
|
|
||||||
[providers]
|
[providers]
|
||||||
[providers.file]
|
[providers.file]
|
71
integration/fixtures/tracing/simple-zipkin.toml
Normal file
71
integration/fixtures/tracing/simple-zipkin.toml
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
[global]
|
||||||
|
checkNewVersion = false
|
||||||
|
sendAnonymousUsage = false
|
||||||
|
|
||||||
|
[log]
|
||||||
|
level = "DEBUG"
|
||||||
|
|
||||||
|
[api]
|
||||||
|
|
||||||
|
[entryPoints]
|
||||||
|
[entryPoints.web]
|
||||||
|
address = ":8000"
|
||||||
|
|
||||||
|
[tracing]
|
||||||
|
servicename = "tracing"
|
||||||
|
[tracing.zipkin]
|
||||||
|
httpEndpoint = "http://{{.IP}}:9411/api/v1/spans"
|
||||||
|
debug = true
|
||||||
|
|
||||||
|
[providers]
|
||||||
|
[providers.file]
|
||||||
|
|
||||||
|
[http.routers]
|
||||||
|
[http.routers.router1]
|
||||||
|
Service = "service1"
|
||||||
|
Middlewares = ["retry", "ratelimit"]
|
||||||
|
Rule = "Path(`/ratelimit`)"
|
||||||
|
[http.routers.router2]
|
||||||
|
Service = "service2"
|
||||||
|
Middlewares = ["retry"]
|
||||||
|
Rule = "Path(`/retry`)"
|
||||||
|
[http.routers.router3]
|
||||||
|
Service = "service3"
|
||||||
|
Middlewares = ["retry", "basic-auth"]
|
||||||
|
Rule = "Path(`/auth`)"
|
||||||
|
|
||||||
|
[http.middlewares]
|
||||||
|
[http.middlewares.retry.retry]
|
||||||
|
attempts = 3
|
||||||
|
[http.middlewares.basic-auth.BasicAuth]
|
||||||
|
users = ["test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"]
|
||||||
|
[http.middlewares.ratelimit.RateLimit]
|
||||||
|
extractorfunc = "client.ip"
|
||||||
|
[http.middlewares.ratelimit.RateLimit.rateset.rateset1]
|
||||||
|
period = "60s"
|
||||||
|
average = 4
|
||||||
|
burst = 5
|
||||||
|
[http.middlewares.ratelimit.RateLimit.rateset.rateset2]
|
||||||
|
period = "3s"
|
||||||
|
average = 1
|
||||||
|
burst = 2
|
||||||
|
|
||||||
|
|
||||||
|
[http.services]
|
||||||
|
[http.services.service1]
|
||||||
|
[http.services.service1.LoadBalancer]
|
||||||
|
passHostHeader = true
|
||||||
|
[[http.services.service1.LoadBalancer.Servers]]
|
||||||
|
URL = "http://{{.WhoAmiIP}}:{{.WhoAmiPort}}"
|
||||||
|
|
||||||
|
[http.services.service2]
|
||||||
|
passHostHeader = true
|
||||||
|
[http.services.service2.LoadBalancer]
|
||||||
|
[[http.services.service2.LoadBalancer.Servers]]
|
||||||
|
URL = "http://{{.WhoAmiIP}}:{{.WhoAmiPort}}"
|
||||||
|
|
||||||
|
[http.services.service3]
|
||||||
|
passHostHeader = true
|
||||||
|
[http.services.service3.LoadBalancer]
|
||||||
|
[[http.services.service3.LoadBalancer.Servers]]
|
||||||
|
URL = "http://{{.WhoAmiIP}}:{{.WhoAmiPort}}"
|
|
@ -6,7 +6,7 @@ zipkin:
|
||||||
ports:
|
ports:
|
||||||
- 9411:9411
|
- 9411:9411
|
||||||
jaeger:
|
jaeger:
|
||||||
image: jaegertracing/all-in-one:latest
|
image: jaegertracing/all-in-one:1.12
|
||||||
environment:
|
environment:
|
||||||
COLLECTOR_ZIPKIN_HTTP_PORT: 9411
|
COLLECTOR_ZIPKIN_HTTP_PORT: 9411
|
||||||
ports:
|
ports:
|
||||||
|
|
|
@ -12,17 +12,15 @@ import (
|
||||||
|
|
||||||
type TracingSuite struct {
|
type TracingSuite struct {
|
||||||
BaseSuite
|
BaseSuite
|
||||||
WhoAmiIP string
|
WhoAmiIP string
|
||||||
WhoAmiPort int
|
WhoAmiPort int
|
||||||
ZipkinIP string
|
IP string
|
||||||
TracingBackend string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type TracingTemplate struct {
|
type TracingTemplate struct {
|
||||||
WhoAmiIP string
|
WhoAmiIP string
|
||||||
WhoAmiPort int
|
WhoAmiPort int
|
||||||
ZipkinIP string
|
IP string
|
||||||
TracingBackend string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TracingSuite) SetUpSuite(c *check.C) {
|
func (s *TracingSuite) SetUpSuite(c *check.C) {
|
||||||
|
@ -35,21 +33,20 @@ func (s *TracingSuite) SetUpSuite(c *check.C) {
|
||||||
|
|
||||||
func (s *TracingSuite) startZipkin(c *check.C) {
|
func (s *TracingSuite) startZipkin(c *check.C) {
|
||||||
s.composeProject.Start(c, "zipkin")
|
s.composeProject.Start(c, "zipkin")
|
||||||
s.ZipkinIP = s.composeProject.Container(c, "zipkin").NetworkSettings.IPAddress
|
s.IP = s.composeProject.Container(c, "zipkin").NetworkSettings.IPAddress
|
||||||
s.TracingBackend = "zipkin"
|
|
||||||
|
|
||||||
// Wait for Zipkin to turn ready.
|
// Wait for Zipkin to turn ready.
|
||||||
err := try.GetRequest("http://"+s.ZipkinIP+":9411/api/v2/services", 20*time.Second, try.StatusCodeIs(http.StatusOK))
|
err := try.GetRequest("http://"+s.IP+":9411/api/v2/services", 20*time.Second, try.StatusCodeIs(http.StatusOK))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TracingSuite) TestZipkinRateLimit(c *check.C) {
|
func (s *TracingSuite) TestZipkinRateLimit(c *check.C) {
|
||||||
s.startZipkin(c)
|
s.startZipkin(c)
|
||||||
file := s.adaptFile(c, "fixtures/tracing/simple.toml", TracingTemplate{
|
defer s.composeProject.Stop(c, "zipkin")
|
||||||
WhoAmiIP: s.WhoAmiIP,
|
file := s.adaptFile(c, "fixtures/tracing/simple-zipkin.toml", TracingTemplate{
|
||||||
WhoAmiPort: s.WhoAmiPort,
|
WhoAmiIP: s.WhoAmiIP,
|
||||||
ZipkinIP: s.ZipkinIP,
|
WhoAmiPort: s.WhoAmiPort,
|
||||||
TracingBackend: s.TracingBackend,
|
IP: s.IP,
|
||||||
})
|
})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
|
|
||||||
|
@ -89,18 +86,18 @@ func (s *TracingSuite) TestZipkinRateLimit(c *check.C) {
|
||||||
err = try.GetRequest("http://127.0.0.1:8000/ratelimit", 500*time.Millisecond, try.StatusCodeIs(http.StatusTooManyRequests))
|
err = try.GetRequest("http://127.0.0.1:8000/ratelimit", 500*time.Millisecond, try.StatusCodeIs(http.StatusTooManyRequests))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
err = try.GetRequest("http://"+s.ZipkinIP+":9411/api/v2/spans?serviceName=tracing", 20*time.Second, try.BodyContains("forward service1/router1@file", "ratelimit@file"))
|
err = try.GetRequest("http://"+s.IP+":9411/api/v2/spans?serviceName=tracing", 20*time.Second, try.BodyContains("forward service1/router1@file", "ratelimit@file"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TracingSuite) TestZipkinRetry(c *check.C) {
|
func (s *TracingSuite) TestZipkinRetry(c *check.C) {
|
||||||
s.startZipkin(c)
|
s.startZipkin(c)
|
||||||
file := s.adaptFile(c, "fixtures/tracing/simple.toml", TracingTemplate{
|
defer s.composeProject.Stop(c, "zipkin")
|
||||||
WhoAmiIP: s.WhoAmiIP,
|
file := s.adaptFile(c, "fixtures/tracing/simple-zipkin.toml", TracingTemplate{
|
||||||
WhoAmiPort: 81,
|
WhoAmiIP: s.WhoAmiIP,
|
||||||
ZipkinIP: s.ZipkinIP,
|
WhoAmiPort: 81,
|
||||||
TracingBackend: s.TracingBackend,
|
IP: s.IP,
|
||||||
})
|
})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
|
|
||||||
|
@ -117,17 +114,17 @@ func (s *TracingSuite) TestZipkinRetry(c *check.C) {
|
||||||
err = try.GetRequest("http://127.0.0.1:8000/retry", 500*time.Millisecond, try.StatusCodeIs(http.StatusBadGateway))
|
err = try.GetRequest("http://127.0.0.1:8000/retry", 500*time.Millisecond, try.StatusCodeIs(http.StatusBadGateway))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
err = try.GetRequest("http://"+s.ZipkinIP+":9411/api/v2/spans?serviceName=tracing", 20*time.Second, try.BodyContains("forward service2/router2@file", "retry@file"))
|
err = try.GetRequest("http://"+s.IP+":9411/api/v2/spans?serviceName=tracing", 20*time.Second, try.BodyContains("forward service2/router2@file", "retry@file"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TracingSuite) TestZipkinAuth(c *check.C) {
|
func (s *TracingSuite) TestZipkinAuth(c *check.C) {
|
||||||
s.startZipkin(c)
|
s.startZipkin(c)
|
||||||
file := s.adaptFile(c, "fixtures/tracing/simple.toml", TracingTemplate{
|
defer s.composeProject.Stop(c, "zipkin")
|
||||||
WhoAmiIP: s.WhoAmiIP,
|
file := s.adaptFile(c, "fixtures/tracing/simple-zipkin.toml", TracingTemplate{
|
||||||
WhoAmiPort: s.WhoAmiPort,
|
WhoAmiIP: s.WhoAmiIP,
|
||||||
ZipkinIP: s.ZipkinIP,
|
WhoAmiPort: s.WhoAmiPort,
|
||||||
TracingBackend: s.TracingBackend,
|
IP: s.IP,
|
||||||
})
|
})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
|
|
||||||
|
@ -144,6 +141,120 @@ func (s *TracingSuite) TestZipkinAuth(c *check.C) {
|
||||||
err = try.GetRequest("http://127.0.0.1:8000/auth", 500*time.Millisecond, try.StatusCodeIs(http.StatusUnauthorized))
|
err = try.GetRequest("http://127.0.0.1:8000/auth", 500*time.Millisecond, try.StatusCodeIs(http.StatusUnauthorized))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
err = try.GetRequest("http://"+s.ZipkinIP+":9411/api/v2/spans?serviceName=tracing", 20*time.Second, try.BodyContains("entrypoint web", "basic-auth@file"))
|
err = try.GetRequest("http://"+s.IP+":9411/api/v2/spans?serviceName=tracing", 20*time.Second, try.BodyContains("entrypoint web", "basic-auth@file"))
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *TracingSuite) startJaeger(c *check.C) {
|
||||||
|
s.composeProject.Start(c, "jaeger")
|
||||||
|
s.IP = s.composeProject.Container(c, "jaeger").NetworkSettings.IPAddress
|
||||||
|
|
||||||
|
// Wait for Jaeger to turn ready.
|
||||||
|
err := try.GetRequest("http://"+s.IP+":16686/api/services", 20*time.Second, try.StatusCodeIs(http.StatusOK))
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *TracingSuite) TestJaegerRateLimit(c *check.C) {
|
||||||
|
s.startJaeger(c)
|
||||||
|
defer s.composeProject.Stop(c, "jaeger")
|
||||||
|
file := s.adaptFile(c, "fixtures/tracing/simple-jaeger.toml", TracingTemplate{
|
||||||
|
WhoAmiIP: s.WhoAmiIP,
|
||||||
|
WhoAmiPort: s.WhoAmiPort,
|
||||||
|
IP: s.IP,
|
||||||
|
})
|
||||||
|
defer os.Remove(file)
|
||||||
|
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
|
err := cmd.Start()
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
defer cmd.Process.Kill()
|
||||||
|
|
||||||
|
// wait for traefik
|
||||||
|
err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", time.Second, try.BodyContains("basic-auth"))
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
|
err = try.GetRequest("http://127.0.0.1:8000/ratelimit", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK))
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
err = try.GetRequest("http://127.0.0.1:8000/ratelimit", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK))
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
err = try.GetRequest("http://127.0.0.1:8000/ratelimit", 500*time.Millisecond, try.StatusCodeIs(http.StatusTooManyRequests))
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
|
// sleep for 4 seconds to be certain the configured time period has elapsed
|
||||||
|
// then test another request and verify a 200 status code
|
||||||
|
time.Sleep(4 * time.Second)
|
||||||
|
err = try.GetRequest("http://127.0.0.1:8000/ratelimit", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK))
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
|
// continue requests at 3 second intervals to test the other rate limit time period
|
||||||
|
time.Sleep(3 * time.Second)
|
||||||
|
err = try.GetRequest("http://127.0.0.1:8000/ratelimit", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK))
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
|
time.Sleep(3 * time.Second)
|
||||||
|
err = try.GetRequest("http://127.0.0.1:8000/ratelimit", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK))
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
|
time.Sleep(3 * time.Second)
|
||||||
|
err = try.GetRequest("http://127.0.0.1:8000/ratelimit", 500*time.Millisecond, try.StatusCodeIs(http.StatusTooManyRequests))
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
|
err = try.GetRequest("http://"+s.IP+":16686/api/traces?service=tracing", 20*time.Second, try.BodyContains("forward service1/router1@file", "ratelimit@file"))
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *TracingSuite) TestJaegerRetry(c *check.C) {
|
||||||
|
s.startJaeger(c)
|
||||||
|
defer s.composeProject.Stop(c, "jaeger")
|
||||||
|
file := s.adaptFile(c, "fixtures/tracing/simple-jaeger.toml", TracingTemplate{
|
||||||
|
WhoAmiIP: s.WhoAmiIP,
|
||||||
|
WhoAmiPort: 81,
|
||||||
|
IP: s.IP,
|
||||||
|
})
|
||||||
|
defer os.Remove(file)
|
||||||
|
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
|
err := cmd.Start()
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
defer cmd.Process.Kill()
|
||||||
|
|
||||||
|
// wait for traefik
|
||||||
|
err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", time.Second, try.BodyContains("basic-auth"))
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
|
err = try.GetRequest("http://127.0.0.1:8000/retry", 500*time.Millisecond, try.StatusCodeIs(http.StatusBadGateway))
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
|
err = try.GetRequest("http://"+s.IP+":16686/api/traces?service=tracing", 20*time.Second, try.BodyContains("forward service2/router2@file", "retry@file"))
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *TracingSuite) TestJaegerAuth(c *check.C) {
|
||||||
|
s.startJaeger(c)
|
||||||
|
defer s.composeProject.Stop(c, "jaeger")
|
||||||
|
file := s.adaptFile(c, "fixtures/tracing/simple-jaeger.toml", TracingTemplate{
|
||||||
|
WhoAmiIP: s.WhoAmiIP,
|
||||||
|
WhoAmiPort: s.WhoAmiPort,
|
||||||
|
IP: s.IP,
|
||||||
|
})
|
||||||
|
defer os.Remove(file)
|
||||||
|
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
|
err := cmd.Start()
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
defer cmd.Process.Kill()
|
||||||
|
|
||||||
|
// wait for traefik
|
||||||
|
err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", time.Second, try.BodyContains("basic-auth"))
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
|
err = try.GetRequest("http://127.0.0.1:8000/auth", 500*time.Millisecond, try.StatusCodeIs(http.StatusUnauthorized))
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
|
err = try.GetRequest("http://"+s.IP+":16686/api/traces?service=tracing", 20*time.Second, try.BodyContains("EntryPoint web", "basic-auth@file"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"github.com/containous/traefik/pkg/provider/kubernetes/ingress"
|
"github.com/containous/traefik/pkg/provider/kubernetes/ingress"
|
||||||
traefiktls "github.com/containous/traefik/pkg/tls"
|
traefiktls "github.com/containous/traefik/pkg/tls"
|
||||||
"github.com/containous/traefik/pkg/tracing/datadog"
|
"github.com/containous/traefik/pkg/tracing/datadog"
|
||||||
|
"github.com/containous/traefik/pkg/tracing/haystack"
|
||||||
"github.com/containous/traefik/pkg/tracing/instana"
|
"github.com/containous/traefik/pkg/tracing/instana"
|
||||||
"github.com/containous/traefik/pkg/tracing/jaeger"
|
"github.com/containous/traefik/pkg/tracing/jaeger"
|
||||||
"github.com/containous/traefik/pkg/tracing/zipkin"
|
"github.com/containous/traefik/pkg/tracing/zipkin"
|
||||||
|
@ -223,7 +224,6 @@ func TestDo_globalConfiguration(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Tracing = &static.Tracing{
|
config.Tracing = &static.Tracing{
|
||||||
Backend: "myBackend",
|
|
||||||
ServiceName: "myServiceName",
|
ServiceName: "myServiceName",
|
||||||
SpanNameLimit: 3,
|
SpanNameLimit: 3,
|
||||||
Jaeger: &jaeger.Config{
|
Jaeger: &jaeger.Config{
|
||||||
|
@ -253,6 +253,15 @@ func TestDo_globalConfiguration(t *testing.T) {
|
||||||
LocalAgentPort: 32,
|
LocalAgentPort: 32,
|
||||||
LogLevel: "ggg",
|
LogLevel: "ggg",
|
||||||
},
|
},
|
||||||
|
Haystack: &haystack.Config{
|
||||||
|
LocalAgentHost: "fff",
|
||||||
|
LocalAgentPort: 32,
|
||||||
|
GlobalTag: "eee",
|
||||||
|
TraceIDHeaderName: "fff",
|
||||||
|
ParentIDHeaderName: "ggg",
|
||||||
|
SpanIDHeaderName: "hhh",
|
||||||
|
BaggagePrefixHeaderName: "iii",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
config.HostResolver = &types.HostResolverConfig{
|
config.HostResolver = &types.HostResolverConfig{
|
||||||
|
|
|
@ -292,7 +292,6 @@ func Test_decodeFileToNode_Toml(t *testing.T) {
|
||||||
{Name: "MaxIdleConnsPerHost", Value: "42"},
|
{Name: "MaxIdleConnsPerHost", Value: "42"},
|
||||||
{Name: "RootCAs", Value: "foobar,foobar"}}},
|
{Name: "RootCAs", Value: "foobar,foobar"}}},
|
||||||
{Name: "Tracing", Children: []*parser.Node{
|
{Name: "Tracing", Children: []*parser.Node{
|
||||||
{Name: "Backend", Value: "foobar"},
|
|
||||||
{Name: "DataDog", Children: []*parser.Node{
|
{Name: "DataDog", Children: []*parser.Node{
|
||||||
{Name: "BagagePrefixHeaderName", Value: "foobar"},
|
{Name: "BagagePrefixHeaderName", Value: "foobar"},
|
||||||
{Name: "Debug", Value: "true"},
|
{Name: "Debug", Value: "true"},
|
||||||
|
@ -302,6 +301,13 @@ func Test_decodeFileToNode_Toml(t *testing.T) {
|
||||||
{Name: "PrioritySampling", Value: "true"},
|
{Name: "PrioritySampling", Value: "true"},
|
||||||
{Name: "SamplingPriorityHeaderName", Value: "foobar"},
|
{Name: "SamplingPriorityHeaderName", Value: "foobar"},
|
||||||
{Name: "TraceIDHeaderName", Value: "foobar"}}},
|
{Name: "TraceIDHeaderName", Value: "foobar"}}},
|
||||||
|
{Name: "Haystack", Children: []*parser.Node{
|
||||||
|
{Name: "GlobalTag", Value: "foobar"},
|
||||||
|
{Name: "LocalAgentHost", Value: "foobar"},
|
||||||
|
{Name: "LocalAgentPort", Value: "42"},
|
||||||
|
{Name: "ParentIDHeaderName", Value: "foobar"},
|
||||||
|
{Name: "SpanIDHeaderName", Value: "foobar"},
|
||||||
|
{Name: "TraceIDHeaderName", Value: "foobar"}}},
|
||||||
{Name: "Instana", Children: []*parser.Node{
|
{Name: "Instana", Children: []*parser.Node{
|
||||||
{Name: "LocalAgentHost", Value: "foobar"},
|
{Name: "LocalAgentHost", Value: "foobar"},
|
||||||
{Name: "LocalAgentPort", Value: "42"},
|
{Name: "LocalAgentPort", Value: "42"},
|
||||||
|
@ -561,7 +567,6 @@ func Test_decodeFileToNode_Yaml(t *testing.T) {
|
||||||
{Name: "MaxIdleConnsPerHost", Value: "42"},
|
{Name: "MaxIdleConnsPerHost", Value: "42"},
|
||||||
{Name: "RootCAs", Value: "foobar,foobar"}}},
|
{Name: "RootCAs", Value: "foobar,foobar"}}},
|
||||||
{Name: "Tracing", Children: []*parser.Node{
|
{Name: "Tracing", Children: []*parser.Node{
|
||||||
{Name: "Backend", Value: "foobar"},
|
|
||||||
{Name: "DataDog", Children: []*parser.Node{
|
{Name: "DataDog", Children: []*parser.Node{
|
||||||
{Name: "BagagePrefixHeaderName", Value: "foobar"},
|
{Name: "BagagePrefixHeaderName", Value: "foobar"},
|
||||||
{Name: "Debug", Value: "true"},
|
{Name: "Debug", Value: "true"},
|
||||||
|
@ -571,6 +576,13 @@ func Test_decodeFileToNode_Yaml(t *testing.T) {
|
||||||
{Name: "PrioritySampling", Value: "true"},
|
{Name: "PrioritySampling", Value: "true"},
|
||||||
{Name: "SamplingPriorityHeaderName", Value: "foobar"},
|
{Name: "SamplingPriorityHeaderName", Value: "foobar"},
|
||||||
{Name: "TraceIDHeaderName", Value: "foobar"}}},
|
{Name: "TraceIDHeaderName", Value: "foobar"}}},
|
||||||
|
{Name: "Haystack", Children: []*parser.Node{
|
||||||
|
{Name: "GlobalTag", Value: "foobar"},
|
||||||
|
{Name: "LocalAgentHost", Value: "foobar"},
|
||||||
|
{Name: "LocalAgentPort", Value: "42"},
|
||||||
|
{Name: "ParentIDHeaderName", Value: "foobar"},
|
||||||
|
{Name: "SpanIDHeaderName", Value: "foobar"},
|
||||||
|
{Name: "TraceIDHeaderName", Value: "foobar"}}},
|
||||||
{Name: "Instana", Children: []*parser.Node{
|
{Name: "Instana", Children: []*parser.Node{
|
||||||
{Name: "LocalAgentHost", Value: "foobar"},
|
{Name: "LocalAgentHost", Value: "foobar"},
|
||||||
{Name: "LocalAgentPort", Value: "42"},
|
{Name: "LocalAgentPort", Value: "42"},
|
||||||
|
|
|
@ -205,7 +205,6 @@
|
||||||
name1 = "foobar"
|
name1 = "foobar"
|
||||||
|
|
||||||
[Tracing]
|
[Tracing]
|
||||||
Backend = "foobar"
|
|
||||||
ServiceName = "foobar"
|
ServiceName = "foobar"
|
||||||
SpanNameLimit = 42
|
SpanNameLimit = 42
|
||||||
|
|
||||||
|
@ -240,6 +239,14 @@
|
||||||
LocalAgentPort = 42
|
LocalAgentPort = 42
|
||||||
LogLevel = "foobar"
|
LogLevel = "foobar"
|
||||||
|
|
||||||
|
[Tracing.Haystack]
|
||||||
|
GlobalTag = "foobar"
|
||||||
|
LocalAgentHost = "foobar"
|
||||||
|
LocalAgentPort = 42
|
||||||
|
ParentIDHeaderName = "foobar"
|
||||||
|
SpanIDHeaderName = "foobar"
|
||||||
|
TraceIDHeaderName = "foobar"
|
||||||
|
|
||||||
[HostResolver]
|
[HostResolver]
|
||||||
CnameFlattening = true
|
CnameFlattening = true
|
||||||
ResolvConfig = "foobar"
|
ResolvConfig = "foobar"
|
||||||
|
|
|
@ -193,7 +193,6 @@ AccessLog:
|
||||||
name0: foobar
|
name0: foobar
|
||||||
name1: foobar
|
name1: foobar
|
||||||
Tracing:
|
Tracing:
|
||||||
Backend: foobar
|
|
||||||
ServiceName: foobar
|
ServiceName: foobar
|
||||||
SpanNameLimit: 42
|
SpanNameLimit: 42
|
||||||
Jaeger:
|
Jaeger:
|
||||||
|
@ -223,6 +222,13 @@ Tracing:
|
||||||
LocalAgentHost: foobar
|
LocalAgentHost: foobar
|
||||||
LocalAgentPort: 42
|
LocalAgentPort: 42
|
||||||
LogLevel: foobar
|
LogLevel: foobar
|
||||||
|
Haystack:
|
||||||
|
GlobalTag: foobar
|
||||||
|
LocalAgentHost: foobar
|
||||||
|
LocalAgentPort: 42
|
||||||
|
ParentIDHeaderName: foobar
|
||||||
|
TraceIDHeaderName: foobar
|
||||||
|
SpanIDHeaderName: foobar
|
||||||
HostResolver:
|
HostResolver:
|
||||||
CnameFlattening: true
|
CnameFlattening: true
|
||||||
ResolvConfig: foobar
|
ResolvConfig: foobar
|
||||||
|
|
|
@ -24,7 +24,6 @@ import (
|
||||||
"github.com/containous/traefik/pkg/types"
|
"github.com/containous/traefik/pkg/types"
|
||||||
assetfs "github.com/elazarl/go-bindata-assetfs"
|
assetfs "github.com/elazarl/go-bindata-assetfs"
|
||||||
"github.com/go-acme/lego/challenge/dns01"
|
"github.com/go-acme/lego/challenge/dns01"
|
||||||
jaegercli "github.com/uber/jaeger-client-go"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -130,7 +129,6 @@ func (a *LifeCycle) SetDefaults() {
|
||||||
|
|
||||||
// Tracing holds the tracing configuration.
|
// Tracing holds the tracing configuration.
|
||||||
type Tracing struct {
|
type Tracing struct {
|
||||||
Backend string `description:"Selects the tracking backend ('jaeger','zipkin','datadog','instana')." export:"true"`
|
|
||||||
ServiceName string `description:"Set the name for this service." export:"true"`
|
ServiceName string `description:"Set the name for this service." export:"true"`
|
||||||
SpanNameLimit int `description:"Set the maximum character limit for Span names (default 0 = no limit)." export:"true"`
|
SpanNameLimit int `description:"Set the maximum character limit for Span names (default 0 = no limit)." export:"true"`
|
||||||
Jaeger *jaeger.Config `description:"Settings for jaeger." label:"allowEmpty"`
|
Jaeger *jaeger.Config `description:"Settings for jaeger." label:"allowEmpty"`
|
||||||
|
@ -142,7 +140,6 @@ type Tracing struct {
|
||||||
|
|
||||||
// SetDefaults sets the default values.
|
// SetDefaults sets the default values.
|
||||||
func (t *Tracing) SetDefaults() {
|
func (t *Tracing) SetDefaults() {
|
||||||
t.Backend = "jaeger"
|
|
||||||
t.ServiceName = "traefik"
|
t.ServiceName = "traefik"
|
||||||
t.SpanNameLimit = 0
|
t.SpanNameLimit = 0
|
||||||
}
|
}
|
||||||
|
@ -198,103 +195,6 @@ func (c *Configuration) SetEffectiveConfiguration(configFile string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
c.initACMEProvider()
|
c.initACMEProvider()
|
||||||
c.initTracing()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Configuration) initTracing() {
|
|
||||||
if c.Tracing != nil {
|
|
||||||
switch c.Tracing.Backend {
|
|
||||||
case jaeger.Name:
|
|
||||||
if c.Tracing.Jaeger == nil {
|
|
||||||
c.Tracing.Jaeger = &jaeger.Config{
|
|
||||||
SamplingServerURL: "http://localhost:5778/sampling",
|
|
||||||
SamplingType: "const",
|
|
||||||
SamplingParam: 1.0,
|
|
||||||
LocalAgentHostPort: "127.0.0.1:6831",
|
|
||||||
Propagation: "jaeger",
|
|
||||||
Gen128Bit: false,
|
|
||||||
TraceContextHeaderName: jaegercli.TraceContextHeaderName,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if c.Tracing.Zipkin != nil {
|
|
||||||
log.Warn("Zipkin configuration will be ignored")
|
|
||||||
c.Tracing.Zipkin = nil
|
|
||||||
}
|
|
||||||
if c.Tracing.DataDog != nil {
|
|
||||||
log.Warn("DataDog configuration will be ignored")
|
|
||||||
c.Tracing.DataDog = nil
|
|
||||||
}
|
|
||||||
if c.Tracing.Instana != nil {
|
|
||||||
log.Warn("Instana configuration will be ignored")
|
|
||||||
c.Tracing.Instana = nil
|
|
||||||
}
|
|
||||||
case zipkin.Name:
|
|
||||||
if c.Tracing.Zipkin == nil {
|
|
||||||
c.Tracing.Zipkin = &zipkin.Config{
|
|
||||||
HTTPEndpoint: "http://localhost:9411/api/v1/spans",
|
|
||||||
SameSpan: false,
|
|
||||||
ID128Bit: true,
|
|
||||||
Debug: false,
|
|
||||||
SampleRate: 1.0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if c.Tracing.Jaeger != nil {
|
|
||||||
log.Warn("Jaeger configuration will be ignored")
|
|
||||||
c.Tracing.Jaeger = nil
|
|
||||||
}
|
|
||||||
if c.Tracing.DataDog != nil {
|
|
||||||
log.Warn("DataDog configuration will be ignored")
|
|
||||||
c.Tracing.DataDog = nil
|
|
||||||
}
|
|
||||||
if c.Tracing.Instana != nil {
|
|
||||||
log.Warn("Instana configuration will be ignored")
|
|
||||||
c.Tracing.Instana = nil
|
|
||||||
}
|
|
||||||
case datadog.Name:
|
|
||||||
if c.Tracing.DataDog == nil {
|
|
||||||
c.Tracing.DataDog = &datadog.Config{
|
|
||||||
LocalAgentHostPort: "localhost:8126",
|
|
||||||
GlobalTag: "",
|
|
||||||
Debug: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if c.Tracing.Zipkin != nil {
|
|
||||||
log.Warn("Zipkin configuration will be ignored")
|
|
||||||
c.Tracing.Zipkin = nil
|
|
||||||
}
|
|
||||||
if c.Tracing.Jaeger != nil {
|
|
||||||
log.Warn("Jaeger configuration will be ignored")
|
|
||||||
c.Tracing.Jaeger = nil
|
|
||||||
}
|
|
||||||
if c.Tracing.Instana != nil {
|
|
||||||
log.Warn("Instana configuration will be ignored")
|
|
||||||
c.Tracing.Instana = nil
|
|
||||||
}
|
|
||||||
case instana.Name:
|
|
||||||
if c.Tracing.Instana == nil {
|
|
||||||
c.Tracing.Instana = &instana.Config{
|
|
||||||
LocalAgentHost: "localhost",
|
|
||||||
LocalAgentPort: 42699,
|
|
||||||
LogLevel: "info",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if c.Tracing.Zipkin != nil {
|
|
||||||
log.Warn("Zipkin configuration will be ignored")
|
|
||||||
c.Tracing.Zipkin = nil
|
|
||||||
}
|
|
||||||
if c.Tracing.Jaeger != nil {
|
|
||||||
log.Warn("Jaeger configuration will be ignored")
|
|
||||||
c.Tracing.Jaeger = nil
|
|
||||||
}
|
|
||||||
if c.Tracing.DataDog != nil {
|
|
||||||
log.Warn("DataDog configuration will be ignored")
|
|
||||||
c.Tracing.DataDog = nil
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
log.Warnf("Unknown tracer %q", c.Tracing.Backend)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME handle on new configuration ACME struct
|
// FIXME handle on new configuration ACME struct
|
||||||
|
|
|
@ -20,10 +20,7 @@ import (
|
||||||
"github.com/containous/traefik/pkg/server/middleware"
|
"github.com/containous/traefik/pkg/server/middleware"
|
||||||
"github.com/containous/traefik/pkg/tls"
|
"github.com/containous/traefik/pkg/tls"
|
||||||
"github.com/containous/traefik/pkg/tracing"
|
"github.com/containous/traefik/pkg/tracing"
|
||||||
"github.com/containous/traefik/pkg/tracing/datadog"
|
|
||||||
"github.com/containous/traefik/pkg/tracing/instana"
|
|
||||||
"github.com/containous/traefik/pkg/tracing/jaeger"
|
"github.com/containous/traefik/pkg/tracing/jaeger"
|
||||||
"github.com/containous/traefik/pkg/tracing/zipkin"
|
|
||||||
"github.com/containous/traefik/pkg/types"
|
"github.com/containous/traefik/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -53,20 +50,52 @@ type RouteAppenderFactory interface {
|
||||||
NewAppender(ctx context.Context, middlewaresBuilder *middleware.Builder, runtimeConfiguration *config.RuntimeConfiguration) types.RouteAppender
|
NewAppender(ctx context.Context, middlewaresBuilder *middleware.Builder, runtimeConfiguration *config.RuntimeConfiguration) types.RouteAppender
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupTracing(conf *static.Tracing) tracing.TrackingBackend {
|
func setupTracing(conf *static.Tracing) tracing.Backend {
|
||||||
switch conf.Backend {
|
var backend tracing.Backend
|
||||||
case jaeger.Name:
|
|
||||||
return conf.Jaeger
|
if conf.Jaeger != nil {
|
||||||
case zipkin.Name:
|
backend = conf.Jaeger
|
||||||
return conf.Zipkin
|
|
||||||
case datadog.Name:
|
|
||||||
return conf.DataDog
|
|
||||||
case instana.Name:
|
|
||||||
return conf.Instana
|
|
||||||
default:
|
|
||||||
log.WithoutContext().Warnf("Could not initialize tracing: unknown tracer %q", conf.Backend)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if conf.Zipkin != nil {
|
||||||
|
if backend != nil {
|
||||||
|
log.WithoutContext().Error("Multiple tracing backend are not supported: cannot create Zipkin backend.")
|
||||||
|
} else {
|
||||||
|
backend = conf.Zipkin
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if conf.DataDog != nil {
|
||||||
|
if backend != nil {
|
||||||
|
log.WithoutContext().Error("Multiple tracing backend are not supported: cannot create DataDog backend.")
|
||||||
|
} else {
|
||||||
|
backend = conf.DataDog
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if conf.Instana != nil {
|
||||||
|
if backend != nil {
|
||||||
|
log.WithoutContext().Error("Multiple tracing backend are not supported: cannot create Instana backend.")
|
||||||
|
} else {
|
||||||
|
backend = conf.Instana
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if conf.Haystack != nil {
|
||||||
|
if backend != nil {
|
||||||
|
log.WithoutContext().Error("Multiple tracing backend are not supported: cannot create Haystack backend.")
|
||||||
|
} else {
|
||||||
|
backend = conf.Haystack
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if backend == nil {
|
||||||
|
log.WithoutContext().Debug("Could not initialize tracing, use Jaeger by default")
|
||||||
|
backend := &jaeger.Config{}
|
||||||
|
backend.SetDefaults()
|
||||||
|
}
|
||||||
|
|
||||||
|
return backend
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewServer returns an initialized Server.
|
// NewServer returns an initialized Server.
|
||||||
|
@ -100,11 +129,12 @@ func NewServer(staticConfiguration static.Configuration, provider provider.Provi
|
||||||
server.routinesPool = safe.NewPool(context.Background())
|
server.routinesPool = safe.NewPool(context.Background())
|
||||||
|
|
||||||
if staticConfiguration.Tracing != nil {
|
if staticConfiguration.Tracing != nil {
|
||||||
trackingBackend := setupTracing(staticConfiguration.Tracing)
|
tracingBackend := setupTracing(staticConfiguration.Tracing)
|
||||||
var err error
|
if tracingBackend != nil {
|
||||||
server.tracer, err = tracing.NewTracing(staticConfiguration.Tracing.ServiceName, staticConfiguration.Tracing.SpanNameLimit, trackingBackend)
|
server.tracer, err = tracing.NewTracing(staticConfiguration.Tracing.ServiceName, staticConfiguration.Tracing.SpanNameLimit, tracingBackend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithoutContext().Warnf("Unable to create tracer: %v", err)
|
log.WithoutContext().Warnf("Unable to create tracer: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ type Config struct {
|
||||||
TraceIDHeaderName string `description:"Specifies the header name that will be used to store the trace ID." export:"true"`
|
TraceIDHeaderName string `description:"Specifies the header name that will be used to store the trace ID." export:"true"`
|
||||||
ParentIDHeaderName string `description:"Specifies the header name that will be used to store the parent ID." export:"true"`
|
ParentIDHeaderName string `description:"Specifies the header name that will be used to store the parent ID." export:"true"`
|
||||||
SpanIDHeaderName string `description:"Specifies the header name that will be used to store the span ID." export:"true"`
|
SpanIDHeaderName string `description:"Specifies the header name that will be used to store the span ID." export:"true"`
|
||||||
BaggagePrefixHeaderName string `description:"specifies the header name prefix that will be used to store baggage items in a map." export:"true"`
|
BaggagePrefixHeaderName string `description:"Specifies the header name prefix that will be used to store baggage items in a map." export:"true"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDefaults sets the default values.
|
// SetDefaults sets the default values.
|
||||||
|
|
|
@ -38,8 +38,8 @@ func FromContext(ctx context.Context) (*Tracing, error) {
|
||||||
return tracer, nil
|
return tracer, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TrackingBackend is an abstraction for tracking backend (Jaeger, Zipkin, ...).
|
// Backend is an abstraction for tracking backend (Jaeger, Zipkin, ...).
|
||||||
type TrackingBackend interface {
|
type Backend interface {
|
||||||
Setup(componentName string) (opentracing.Tracer, io.Closer, error)
|
Setup(componentName string) (opentracing.Tracer, io.Closer, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,14 +53,14 @@ type Tracing struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTracing Creates a Tracing.
|
// NewTracing Creates a Tracing.
|
||||||
func NewTracing(serviceName string, spanNameLimit int, trackingBackend TrackingBackend) (*Tracing, error) {
|
func NewTracing(serviceName string, spanNameLimit int, tracingBackend Backend) (*Tracing, error) {
|
||||||
tracing := &Tracing{
|
tracing := &Tracing{
|
||||||
ServiceName: serviceName,
|
ServiceName: serviceName,
|
||||||
SpanNameLimit: spanNameLimit,
|
SpanNameLimit: spanNameLimit,
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
tracing.tracer, tracing.closer, err = trackingBackend.Setup(serviceName)
|
tracing.tracer, tracing.closer, err = tracingBackend.Setup(serviceName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue