Merge branch 'v3.0' of github.com:traefik/traefik

This commit is contained in:
baalajimaestro 2024-02-06 16:26:30 +05:30
commit 56b53107a6
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5
20 changed files with 645 additions and 389 deletions

View file

@ -520,15 +520,14 @@ func registerMetricClients(metricsConfig *types.Metrics) []metrics.Registry {
} }
} }
if metricsConfig.OpenTelemetry != nil { if metricsConfig.OTLP != nil {
logger := log.With().Str(logs.MetricsProviderName, "openTelemetry").Logger() logger := log.With().Str(logs.MetricsProviderName, "openTelemetry").Logger()
openTelemetryRegistry := metrics.RegisterOpenTelemetry(logger.WithContext(context.Background()), metricsConfig.OpenTelemetry) openTelemetryRegistry := metrics.RegisterOpenTelemetry(logger.WithContext(context.Background()), metricsConfig.OTLP)
if openTelemetryRegistry != nil { if openTelemetryRegistry != nil {
registries = append(registries, openTelemetryRegistry) registries = append(registries, openTelemetryRegistry)
logger.Debug(). logger.Debug().
Str("address", metricsConfig.OpenTelemetry.Address). Str("pushInterval", metricsConfig.OTLP.PushInterval.String()).
Str("pushInterval", metricsConfig.OpenTelemetry.PushInterval.String()).
Msg("Configured OpenTelemetry metrics") Msg("Configured OpenTelemetry metrics")
} }
} }

View file

@ -5,45 +5,25 @@ description: "Traefik supports several metrics backends, including OpenTelemetry
# OpenTelemetry # OpenTelemetry
To enable the OpenTelemetry: To enable the OpenTelemetry metrics:
```yaml tab="File (YAML)" ```yaml tab="File (YAML)"
metrics: metrics:
openTelemetry: {} otlp: {}
``` ```
```toml tab="File (TOML)" ```toml tab="File (TOML)"
[metrics] [metrics]
[metrics.openTelemetry] [metrics.otlp]
``` ```
```bash tab="CLI" ```bash tab="CLI"
--metrics.openTelemetry=true --metrics.otlp=true
``` ```
!!! info "The OpenTelemetry exporter will export metrics to the collector by using HTTP by default, see the [gRPC Section](#grpc-configuration) to use gRPC." !!! info "Default protocol"
#### `address` The OpenTelemetry exporter will export metrics to the collector using HTTP by default to https://localhost:4318/v1/metrics, see the [gRPC Section](#grpc-configuration) to use gRPC.
_Required, Default="localhost:4318", Format="`<host>:<port>`"_
Address of the OpenTelemetry Collector to send metrics to.
```yaml tab="File (YAML)"
metrics:
openTelemetry:
address: localhost:4318
```
```toml tab="File (TOML)"
[metrics]
[metrics.openTelemetry]
address = "localhost:4318"
```
```bash tab="CLI"
--metrics.openTelemetry.address=localhost:4318
```
#### `addEntryPointsLabels` #### `addEntryPointsLabels`
@ -53,18 +33,18 @@ Enable metrics on entry points.
```yaml tab="File (YAML)" ```yaml tab="File (YAML)"
metrics: metrics:
openTelemetry: otlp:
addEntryPointsLabels: true addEntryPointsLabels: true
``` ```
```toml tab="File (TOML)" ```toml tab="File (TOML)"
[metrics] [metrics]
[metrics.openTelemetry] [metrics.otlp]
addEntryPointsLabels = true addEntryPointsLabels = true
``` ```
```bash tab="CLI" ```bash tab="CLI"
--metrics.openTelemetry.addEntryPointsLabels=true --metrics.otlp.addEntryPointsLabels=true
``` ```
#### `addRoutersLabels` #### `addRoutersLabels`
@ -75,18 +55,18 @@ Enable metrics on routers.
```yaml tab="File (YAML)" ```yaml tab="File (YAML)"
metrics: metrics:
openTelemetry: otlp:
addRoutersLabels: true addRoutersLabels: true
``` ```
```toml tab="File (TOML)" ```toml tab="File (TOML)"
[metrics] [metrics]
[metrics.openTelemetry] [metrics.otlp]
addRoutersLabels = true addRoutersLabels = true
``` ```
```bash tab="CLI" ```bash tab="CLI"
--metrics.openTelemetry.addRoutersLabels=true --metrics.otlp.addRoutersLabels=true
``` ```
#### `addServicesLabels` #### `addServicesLabels`
@ -97,18 +77,18 @@ Enable metrics on services.
```yaml tab="File (YAML)" ```yaml tab="File (YAML)"
metrics: metrics:
openTelemetry: otlp:
addServicesLabels: true addServicesLabels: true
``` ```
```toml tab="File (TOML)" ```toml tab="File (TOML)"
[metrics] [metrics]
[metrics.openTelemetry] [metrics.otlp]
addServicesLabels = true addServicesLabels = true
``` ```
```bash tab="CLI" ```bash tab="CLI"
--metrics.openTelemetry.addServicesLabels=true --metrics.otlp.addServicesLabels=true
``` ```
#### `explicitBoundaries` #### `explicitBoundaries`
@ -119,7 +99,7 @@ Explicit boundaries for Histogram data points.
```yaml tab="File (YAML)" ```yaml tab="File (YAML)"
metrics: metrics:
openTelemetry: otlp:
explicitBoundaries: explicitBoundaries:
- 0.1 - 0.1
- 0.3 - 0.3
@ -129,59 +109,12 @@ metrics:
```toml tab="File (TOML)" ```toml tab="File (TOML)"
[metrics] [metrics]
[metrics.openTelemetry] [metrics.otlp]
explicitBoundaries = [0.1,0.3,1.2,5.0] explicitBoundaries = [0.1,0.3,1.2,5.0]
``` ```
```bash tab="CLI" ```bash tab="CLI"
--metrics.openTelemetry.explicitBoundaries=0.1,0.3,1.2,5.0 --metrics.otlp.explicitBoundaries=0.1,0.3,1.2,5.0
```
#### `headers`
_Optional, Default={}_
Additional headers sent with metrics by the reporter to the OpenTelemetry Collector.
```yaml tab="File (YAML)"
metrics:
openTelemetry:
headers:
foo: bar
baz: buz
```
```toml tab="File (TOML)"
[metrics]
[metrics.openTelemetry.headers]
foo = "bar"
baz = "buz"
```
```bash tab="CLI"
--metrics.openTelemetry.headers.foo=bar --metrics.openTelemetry.headers.baz=buz
```
#### `insecure`
_Optional, Default=false_
Allows reporter to send metrics to the OpenTelemetry Collector without using a secured protocol.
```yaml tab="File (YAML)"
metrics:
openTelemetry:
insecure: true
```
```toml tab="File (TOML)"
[metrics]
[metrics.openTelemetry]
insecure = true
```
```bash tab="CLI"
--metrics.openTelemetry.insecure=true
``` ```
#### `pushInterval` #### `pushInterval`
@ -192,48 +125,95 @@ Interval at which metrics are sent to the OpenTelemetry Collector.
```yaml tab="File (YAML)" ```yaml tab="File (YAML)"
metrics: metrics:
openTelemetry: otlp:
pushInterval: 10s pushInterval: 10s
``` ```
```toml tab="File (TOML)" ```toml tab="File (TOML)"
[metrics] [metrics]
[metrics.openTelemetry] [metrics.otlp]
pushInterval = "10s" pushInterval = "10s"
``` ```
```bash tab="CLI" ```bash tab="CLI"
--metrics.openTelemetry.pushInterval=10s --metrics.otlp.pushInterval=10s
``` ```
#### `path` ### HTTP configuration
_Required, Default="/v1/metrics"_ _Optional_
Allows to override the default URL path used for sending metrics. This instructs the exporter to send the metrics to the OpenTelemetry Collector using HTTP.
This option has no effect when using gRPC transport.
```yaml tab="File (YAML)" ```yaml tab="File (YAML)"
metrics: metrics:
openTelemetry: otlp:
path: /foo/v1/metrics http: {}
``` ```
```toml tab="File (TOML)" ```toml tab="File (TOML)"
[metrics] [metrics]
[metrics.openTelemetry] [metrics.otlp.http]
path = "/foo/v1/metrics"
``` ```
```bash tab="CLI" ```bash tab="CLI"
--metrics.openTelemetry.path=/foo/v1/metrics --metrics.otlp.http=true
```
#### `endpoint`
_Required, Default="http://localhost:4318/v1/metrics", Format="`<scheme>://<host>:<port><path>`"_
URL of the OpenTelemetry Collector to send metrics to.
```yaml tab="File (YAML)"
metrics:
otlp:
http:
endpoint: http://localhost:4318/v1/metrics
```
```toml tab="File (TOML)"
[metrics]
[metrics.otlp.http]
endpoint = "http://localhost:4318/v1/metrics"
```
```bash tab="CLI"
--metrics.otlp.http.endpoint=http://localhost:4318/v1/metrics
```
#### `headers`
_Optional, Default={}_
Additional headers sent with metrics by the exporter to the OpenTelemetry Collector.
```yaml tab="File (YAML)"
metrics:
otlp:
http:
headers:
foo: bar
baz: buz
```
```toml tab="File (TOML)"
[metrics]
[metrics.otlp.http.headers]
foo = "bar"
baz = "buz"
```
```bash tab="CLI"
--metrics.otlp.http.headers.foo=bar --metrics.otlp.http.headers.baz=buz
``` ```
#### `tls` #### `tls`
_Optional_ _Optional_
Defines the TLS configuration used by the reporter to send metrics to the OpenTelemetry Collector. Defines the Client TLS configuration used by the exporter to send metrics to the OpenTelemetry Collector.
##### `ca` ##### `ca`
@ -244,18 +224,19 @@ it defaults to the system bundle.
```yaml tab="File (YAML)" ```yaml tab="File (YAML)"
metrics: metrics:
openTelemetry: otlp:
http:
tls: tls:
ca: path/to/ca.crt ca: path/to/ca.crt
``` ```
```toml tab="File (TOML)" ```toml tab="File (TOML)"
[metrics.openTelemetry.tls] [metrics.otlp.http.tls]
ca = "path/to/ca.crt" ca = "path/to/ca.crt"
``` ```
```bash tab="CLI" ```bash tab="CLI"
--metrics.openTelemetry.tls.ca=path/to/ca.crt --metrics.otlp.http.tls.ca=path/to/ca.crt
``` ```
##### `cert` ##### `cert`
@ -267,21 +248,22 @@ When using this option, setting the `key` option is required.
```yaml tab="File (YAML)" ```yaml tab="File (YAML)"
metrics: metrics:
openTelemetry: otlp:
http:
tls: tls:
cert: path/to/foo.cert cert: path/to/foo.cert
key: path/to/foo.key key: path/to/foo.key
``` ```
```toml tab="File (TOML)" ```toml tab="File (TOML)"
[metrics.openTelemetry.tls] [metrics.otlp.http.tls]
cert = "path/to/foo.cert" cert = "path/to/foo.cert"
key = "path/to/foo.key" key = "path/to/foo.key"
``` ```
```bash tab="CLI" ```bash tab="CLI"
--metrics.openTelemetry.tls.cert=path/to/foo.cert --metrics.otlp.http.tls.cert=path/to/foo.cert
--metrics.openTelemetry.tls.key=path/to/foo.key --metrics.otlp.http.tls.key=path/to/foo.key
``` ```
##### `key` ##### `key`
@ -293,21 +275,22 @@ When using this option, setting the `cert` option is required.
```yaml tab="File (YAML)" ```yaml tab="File (YAML)"
metrics: metrics:
openTelemetry: otlp:
http:
tls: tls:
cert: path/to/foo.cert cert: path/to/foo.cert
key: path/to/foo.key key: path/to/foo.key
``` ```
```toml tab="File (TOML)" ```toml tab="File (TOML)"
[metrics.openTelemetry.tls] [metrics.otlp.http.tls]
cert = "path/to/foo.cert" cert = "path/to/foo.cert"
key = "path/to/foo.key" key = "path/to/foo.key"
``` ```
```bash tab="CLI" ```bash tab="CLI"
--metrics.openTelemetry.tls.cert=path/to/foo.cert --metrics.otlp.http.tls.cert=path/to/foo.cert
--metrics.openTelemetry.tls.key=path/to/foo.key --metrics.otlp.http.tls.key=path/to/foo.key
``` ```
##### `insecureSkipVerify` ##### `insecureSkipVerify`
@ -319,35 +302,218 @@ the TLS connection to the OpenTelemetry Collector accepts any certificate presen
```yaml tab="File (YAML)" ```yaml tab="File (YAML)"
metrics: metrics:
openTelemetry: otlp:
http:
tls: tls:
insecureSkipVerify: true insecureSkipVerify: true
``` ```
```toml tab="File (TOML)" ```toml tab="File (TOML)"
[metrics.openTelemetry.tls] [metrics.otlp.http.tls]
insecureSkipVerify = true insecureSkipVerify = true
``` ```
```bash tab="CLI" ```bash tab="CLI"
--metrics.openTelemetry.tls.insecureSkipVerify=true --metrics.otlp.http.tls.insecureSkipVerify=true
``` ```
#### gRPC configuration ### gRPC configuration
This instructs the reporter to send metrics to the OpenTelemetry Collector using gRPC. _Optional_
This instructs the exporter to send metrics to the OpenTelemetry Collector using gRPC.
```yaml tab="File (YAML)" ```yaml tab="File (YAML)"
metrics: metrics:
openTelemetry: otlp:
grpc: {} grpc: {}
``` ```
```toml tab="File (TOML)" ```toml tab="File (TOML)"
[metrics] [metrics]
[metrics.openTelemetry.grpc] [metrics.otlp.grpc]
``` ```
```bash tab="CLI" ```bash tab="CLI"
--metrics.openTelemetry.grpc=true --metrics.otlp.grpc=true
```
#### `endpoint`
_Required, Default="localhost:4317", Format="`<host>:<port>`"_
Address of the OpenTelemetry Collector to send metrics to.
```yaml tab="File (YAML)"
metrics:
otlp:
grpc:
endpoint: localhost:4317
```
```toml tab="File (TOML)"
[metrics]
[metrics.otlp.grpc]
endpoint = "localhost:4317"
```
```bash tab="CLI"
--metrics.otlp.grpc.endpoint=localhost:4317
```
#### `insecure`
_Optional, Default=false_
Allows exporter to send metrics to the OpenTelemetry Collector without using a secured protocol.
```yaml tab="File (YAML)"
metrics:
otlp:
grpc:
insecure: true
```
```toml tab="File (TOML)"
[metrics]
[metrics.otlp.grpc]
insecure = true
```
```bash tab="CLI"
--metrics.otlp.grpc.insecure=true
```
#### `headers`
_Optional, Default={}_
Additional headers sent with metrics by the exporter to the OpenTelemetry Collector.
```yaml tab="File (YAML)"
metrics:
otlp:
grpc:
headers:
foo: bar
baz: buz
```
```toml tab="File (TOML)"
[metrics]
[metrics.otlp.grpc.headers]
foo = "bar"
baz = "buz"
```
```bash tab="CLI"
--metrics.otlp.grpc.headers.foo=bar --metrics.otlp.grpc.headers.baz=buz
```
#### `tls`
_Optional_
Defines the Client TLS configuration used by the exporter to send metrics to the OpenTelemetry Collector.
##### `ca`
_Optional_
`ca` is the path to the certificate authority used for the secure connection to the OpenTelemetry Collector,
it defaults to the system bundle.
```yaml tab="File (YAML)"
metrics:
otlp:
grpc:
tls:
ca: path/to/ca.crt
```
```toml tab="File (TOML)"
[metrics.otlp.grpc.tls]
ca = "path/to/ca.crt"
```
```bash tab="CLI"
--metrics.otlp.grpc.tls.ca=path/to/ca.crt
```
##### `cert`
_Optional_
`cert` is the path to the public certificate used for the secure connection to the OpenTelemetry Collector.
When using this option, setting the `key` option is required.
```yaml tab="File (YAML)"
metrics:
otlp:
grpc:
tls:
cert: path/to/foo.cert
key: path/to/foo.key
```
```toml tab="File (TOML)"
[metrics.otlp.grpc.tls]
cert = "path/to/foo.cert"
key = "path/to/foo.key"
```
```bash tab="CLI"
--metrics.otlp.grpc.tls.cert=path/to/foo.cert
--metrics.otlp.grpc.tls.key=path/to/foo.key
```
##### `key`
_Optional_
`key` is the path to the private key used for the secure connection to the OpenTelemetry Collector.
When using this option, setting the `cert` option is required.
```yaml tab="File (YAML)"
metrics:
otlp:
grpc:
tls:
cert: path/to/foo.cert
key: path/to/foo.key
```
```toml tab="File (TOML)"
[metrics.otlp.grpc.tls]
cert = "path/to/foo.cert"
key = "path/to/foo.key"
```
```bash tab="CLI"
--metrics.otlp.grpc.tls.cert=path/to/foo.cert
--metrics.otlp.grpc.tls.key=path/to/foo.key
```
##### `insecureSkipVerify`
_Optional, Default=false_
If `insecureSkipVerify` is `true`,
the TLS connection to the OpenTelemetry Collector accepts any certificate presented by the server regardless of the hostnames it covers.
```yaml tab="File (YAML)"
metrics:
otlp:
grpc:
tls:
insecureSkipVerify: true
```
```toml tab="File (TOML)"
[metrics.otlp.grpc.tls]
insecureSkipVerify = true
```
```bash tab="CLI"
--metrics.otlp.grpc.tls.insecureSkipVerify=true
``` ```

View file

@ -21,19 +21,20 @@ tracing:
--tracing.otlp=true --tracing.otlp=true
``` ```
!!! info "The OpenTelemetry trace reporter will export traces to the collector using HTTP by default (http://localhost:4318/v1/traces), !!! info "Default protocol"
see the [gRPC Section](#grpc-configuration) to use gRPC."
The OpenTelemetry trace exporter will export traces to the collector using HTTP by default to https://localhost:4318/v1/traces, see the [gRPC Section](#grpc-configuration) to use gRPC.
!!! info "Trace sampling" !!! info "Trace sampling"
By default, the OpenTelemetry trace reporter will sample 100% of traces. By default, the OpenTelemetry trace exporter will sample 100% of traces.
See [OpenTelemetry's SDK configuration](https://opentelemetry.io/docs/reference/specification/sdk-environment-variables/#general-sdk-configuration) to customize the sampling strategy. See [OpenTelemetry's SDK configuration](https://opentelemetry.io/docs/reference/specification/sdk-environment-variables/#general-sdk-configuration) to customize the sampling strategy.
### HTTP configuration ### HTTP configuration
_Optional_ _Optional_
This instructs the reporter to send spans to the OpenTelemetry Collector using HTTP. This instructs the exporter to send spans to the OpenTelemetry Collector using HTTP.
```yaml tab="File (YAML)" ```yaml tab="File (YAML)"
tracing: tracing:
@ -73,11 +74,37 @@ tracing:
--tracing.otlp.http.endpoint=http://localhost:4318/v1/traces --tracing.otlp.http.endpoint=http://localhost:4318/v1/traces
``` ```
#### `headers`
_Optional, Default={}_
Additional headers sent with traces by the exporter to the OpenTelemetry Collector.
```yaml tab="File (YAML)"
tracing:
otlp:
http:
headers:
foo: bar
baz: buz
```
```toml tab="File (TOML)"
[tracing]
[tracing.otlp.http.headers]
foo = "bar"
baz = "buz"
```
```bash tab="CLI"
--tracing.otlp.http.headers.foo=bar --tracing.otlp.http.headers.baz=buz
```
#### `tls` #### `tls`
_Optional_ _Optional_
Defines the Client TLS configuration used by the reporter to send spans to the OpenTelemetry Collector. Defines the Client TLS configuration used by the exporter to send spans to the OpenTelemetry Collector.
##### `ca` ##### `ca`
@ -181,11 +208,11 @@ tracing:
--tracing.otlp.http.tls.insecureSkipVerify=true --tracing.otlp.http.tls.insecureSkipVerify=true
``` ```
#### gRPC configuration ### gRPC configuration
_Optional_ _Optional_
This instructs the reporter to send spans to the OpenTelemetry Collector using gRPC. This instructs the exporter to send spans to the OpenTelemetry Collector using gRPC.
```yaml tab="File (YAML)" ```yaml tab="File (YAML)"
tracing: tracing:
@ -228,7 +255,7 @@ tracing:
_Optional, Default=false_ _Optional, Default=false_
Allows reporter to send spans to the OpenTelemetry Collector without using a secured protocol. Allows exporter to send spans to the OpenTelemetry Collector without using a secured protocol.
```yaml tab="File (YAML)" ```yaml tab="File (YAML)"
tracing: tracing:
@ -247,11 +274,37 @@ tracing:
--tracing.otlp.grpc.insecure=true --tracing.otlp.grpc.insecure=true
``` ```
#### `headers`
_Optional, Default={}_
Additional headers sent with traces by the exporter to the OpenTelemetry Collector.
```yaml tab="File (YAML)"
tracing:
otlp:
grpc:
headers:
foo: bar
baz: buz
```
```toml tab="File (TOML)"
[tracing]
[tracing.otlp.grpc.headers]
foo = "bar"
baz = "buz"
```
```bash tab="CLI"
--tracing.otlp.grpc.headers.foo=bar --tracing.otlp.grpc.headers.baz=buz
```
#### `tls` #### `tls`
_Optional_ _Optional_
Defines the Client TLS configuration used by the reporter to send spans to the OpenTelemetry Collector. Defines the Client TLS configuration used by the exporter to send spans to the OpenTelemetry Collector.
##### `ca` ##### `ca`

View file

@ -92,30 +92,6 @@ tracing:
--tracing.sampleRate=0.2 --tracing.sampleRate=0.2
``` ```
#### `headers`
_Optional, Default={}_
Defines additional headers to be sent with the span's payload.
```yaml tab="File (YAML)"
tracing:
headers:
foo: bar
baz: buz
```
```toml tab="File (TOML)"
[tracing]
[tracing.headers]
foo = "bar"
baz = "buz"
```
```bash tab="CLI"
--tracing.headers.foo=bar --tracing.headers.baz=buz
```
#### `globalAttributes` #### `globalAttributes`
_Optional, Default=empty_ _Optional, Default=empty_

View file

@ -324,51 +324,63 @@ InfluxDB v2 push interval. (Default: ```10```)
`--metrics.influxdb2.token`: `--metrics.influxdb2.token`:
InfluxDB v2 access token. InfluxDB v2 access token.
`--metrics.opentelemetry`: `--metrics.otlp`:
OpenTelemetry metrics exporter type. (Default: ```false```) OpenTelemetry metrics exporter type. (Default: ```false```)
`--metrics.opentelemetry.addentrypointslabels`: `--metrics.otlp.addentrypointslabels`:
Enable metrics on entry points. (Default: ```true```) Enable metrics on entry points. (Default: ```true```)
`--metrics.opentelemetry.address`: `--metrics.otlp.addrouterslabels`:
Address (host:port) of the collector endpoint. (Default: ```localhost:4318```)
`--metrics.opentelemetry.addrouterslabels`:
Enable metrics on routers. (Default: ```false```) Enable metrics on routers. (Default: ```false```)
`--metrics.opentelemetry.addserviceslabels`: `--metrics.otlp.addserviceslabels`:
Enable metrics on services. (Default: ```true```) Enable metrics on services. (Default: ```true```)
`--metrics.opentelemetry.explicitboundaries`: `--metrics.otlp.explicitboundaries`:
Boundaries for latency metrics. (Default: ```0.005000, 0.010000, 0.025000, 0.050000, 0.100000, 0.250000, 0.500000, 1.000000, 2.500000, 5.000000, 10.000000```) Boundaries for latency metrics. (Default: ```0.005000, 0.010000, 0.025000, 0.050000, 0.100000, 0.250000, 0.500000, 1.000000, 2.500000, 5.000000, 10.000000```)
`--metrics.opentelemetry.grpc`: `--metrics.otlp.grpc.endpoint`:
gRPC specific configuration for the OpenTelemetry collector. (Default: ```true```) Sets the gRPC endpoint (host:port) of the collector. (Default: ```localhost:4317```)
`--metrics.opentelemetry.headers.<name>`: `--metrics.otlp.grpc.headers.<name>`:
Headers sent with payload. Headers sent with payload.
`--metrics.opentelemetry.insecure`: `--metrics.otlp.grpc.insecure`:
Disables client transport security for the exporter. (Default: ```false```) Disables client transport security for the exporter. (Default: ```false```)
`--metrics.opentelemetry.path`: `--metrics.otlp.grpc.tls.ca`:
Set the URL path of the collector endpoint.
`--metrics.opentelemetry.pushinterval`:
Period between calls to collect a checkpoint. (Default: ```10```)
`--metrics.opentelemetry.tls.ca`:
TLS CA TLS CA
`--metrics.opentelemetry.tls.cert`: `--metrics.otlp.grpc.tls.cert`:
TLS cert TLS cert
`--metrics.opentelemetry.tls.insecureskipverify`: `--metrics.otlp.grpc.tls.insecureskipverify`:
TLS insecure skip verify (Default: ```false```) TLS insecure skip verify (Default: ```false```)
`--metrics.opentelemetry.tls.key`: `--metrics.otlp.grpc.tls.key`:
TLS key TLS key
`--metrics.otlp.http.endpoint`:
Sets the HTTP endpoint (scheme://host:port/path) of the collector. (Default: ```https://localhost:4318```)
`--metrics.otlp.http.headers.<name>`:
Headers sent with payload.
`--metrics.otlp.http.tls.ca`:
TLS CA
`--metrics.otlp.http.tls.cert`:
TLS cert
`--metrics.otlp.http.tls.insecureskipverify`:
TLS insecure skip verify (Default: ```false```)
`--metrics.otlp.http.tls.key`:
TLS key
`--metrics.otlp.pushinterval`:
Period between calls to collect a checkpoint. (Default: ```10```)
`--metrics.prometheus`: `--metrics.prometheus`:
Prometheus metrics exporter type. (Default: ```false```) Prometheus metrics exporter type. (Default: ```false```)
@ -1005,15 +1017,15 @@ Enables tracing for internal services (ping, dashboard, etc...). (Default: ```fa
`--tracing.globalattributes.<name>`: `--tracing.globalattributes.<name>`:
Defines additional attributes (key:value) on all spans. Defines additional attributes (key:value) on all spans.
`--tracing.headers.<name>`:
Defines additional headers to be sent with the payloads.
`--tracing.otlp`: `--tracing.otlp`:
Settings for OpenTelemetry. (Default: ```false```) Settings for OpenTelemetry. (Default: ```false```)
`--tracing.otlp.grpc.endpoint`: `--tracing.otlp.grpc.endpoint`:
Sets the gRPC endpoint (host:port) of the collector. (Default: ```localhost:4317```) Sets the gRPC endpoint (host:port) of the collector. (Default: ```localhost:4317```)
`--tracing.otlp.grpc.headers.<name>`:
Headers sent with payload.
`--tracing.otlp.grpc.insecure`: `--tracing.otlp.grpc.insecure`:
Disables client transport security for the exporter. (Default: ```false```) Disables client transport security for the exporter. (Default: ```false```)
@ -1030,7 +1042,10 @@ TLS insecure skip verify (Default: ```false```)
TLS key TLS key
`--tracing.otlp.http.endpoint`: `--tracing.otlp.http.endpoint`:
Sets the HTTP endpoint (scheme://host:port/v1/traces) of the collector. (Default: ```localhost:4318```) Sets the HTTP endpoint (scheme://host:port/path) of the collector. (Default: ```https://localhost:4318```)
`--tracing.otlp.http.headers.<name>`:
Headers sent with payload.
`--tracing.otlp.http.tls.ca`: `--tracing.otlp.http.tls.ca`:
TLS CA TLS CA

View file

@ -324,51 +324,63 @@ InfluxDB v2 push interval. (Default: ```10```)
`TRAEFIK_METRICS_INFLUXDB2_TOKEN`: `TRAEFIK_METRICS_INFLUXDB2_TOKEN`:
InfluxDB v2 access token. InfluxDB v2 access token.
`TRAEFIK_METRICS_OPENTELEMETRY`: `TRAEFIK_METRICS_OTLP`:
OpenTelemetry metrics exporter type. (Default: ```false```) OpenTelemetry metrics exporter type. (Default: ```false```)
`TRAEFIK_METRICS_OPENTELEMETRY_ADDENTRYPOINTSLABELS`: `TRAEFIK_METRICS_OTLP_ADDENTRYPOINTSLABELS`:
Enable metrics on entry points. (Default: ```true```) Enable metrics on entry points. (Default: ```true```)
`TRAEFIK_METRICS_OPENTELEMETRY_ADDRESS`: `TRAEFIK_METRICS_OTLP_ADDROUTERSLABELS`:
Address (host:port) of the collector endpoint. (Default: ```localhost:4318```)
`TRAEFIK_METRICS_OPENTELEMETRY_ADDROUTERSLABELS`:
Enable metrics on routers. (Default: ```false```) Enable metrics on routers. (Default: ```false```)
`TRAEFIK_METRICS_OPENTELEMETRY_ADDSERVICESLABELS`: `TRAEFIK_METRICS_OTLP_ADDSERVICESLABELS`:
Enable metrics on services. (Default: ```true```) Enable metrics on services. (Default: ```true```)
`TRAEFIK_METRICS_OPENTELEMETRY_EXPLICITBOUNDARIES`: `TRAEFIK_METRICS_OTLP_EXPLICITBOUNDARIES`:
Boundaries for latency metrics. (Default: ```0.005000, 0.010000, 0.025000, 0.050000, 0.100000, 0.250000, 0.500000, 1.000000, 2.500000, 5.000000, 10.000000```) Boundaries for latency metrics. (Default: ```0.005000, 0.010000, 0.025000, 0.050000, 0.100000, 0.250000, 0.500000, 1.000000, 2.500000, 5.000000, 10.000000```)
`TRAEFIK_METRICS_OPENTELEMETRY_GRPC`: `TRAEFIK_METRICS_OTLP_GRPC_ENDPOINT`:
gRPC specific configuration for the OpenTelemetry collector. (Default: ```true```) Sets the gRPC endpoint (host:port) of the collector. (Default: ```localhost:4317```)
`TRAEFIK_METRICS_OPENTELEMETRY_HEADERS_<NAME>`: `TRAEFIK_METRICS_OTLP_GRPC_HEADERS_<NAME>`:
Headers sent with payload. Headers sent with payload.
`TRAEFIK_METRICS_OPENTELEMETRY_INSECURE`: `TRAEFIK_METRICS_OTLP_GRPC_INSECURE`:
Disables client transport security for the exporter. (Default: ```false```) Disables client transport security for the exporter. (Default: ```false```)
`TRAEFIK_METRICS_OPENTELEMETRY_PATH`: `TRAEFIK_METRICS_OTLP_GRPC_TLS_CA`:
Set the URL path of the collector endpoint.
`TRAEFIK_METRICS_OPENTELEMETRY_PUSHINTERVAL`:
Period between calls to collect a checkpoint. (Default: ```10```)
`TRAEFIK_METRICS_OPENTELEMETRY_TLS_CA`:
TLS CA TLS CA
`TRAEFIK_METRICS_OPENTELEMETRY_TLS_CERT`: `TRAEFIK_METRICS_OTLP_GRPC_TLS_CERT`:
TLS cert TLS cert
`TRAEFIK_METRICS_OPENTELEMETRY_TLS_INSECURESKIPVERIFY`: `TRAEFIK_METRICS_OTLP_GRPC_TLS_INSECURESKIPVERIFY`:
TLS insecure skip verify (Default: ```false```) TLS insecure skip verify (Default: ```false```)
`TRAEFIK_METRICS_OPENTELEMETRY_TLS_KEY`: `TRAEFIK_METRICS_OTLP_GRPC_TLS_KEY`:
TLS key TLS key
`TRAEFIK_METRICS_OTLP_HTTP_ENDPOINT`:
Sets the HTTP endpoint (scheme://host:port/path) of the collector. (Default: ```https://localhost:4318```)
`TRAEFIK_METRICS_OTLP_HTTP_HEADERS_<NAME>`:
Headers sent with payload.
`TRAEFIK_METRICS_OTLP_HTTP_TLS_CA`:
TLS CA
`TRAEFIK_METRICS_OTLP_HTTP_TLS_CERT`:
TLS cert
`TRAEFIK_METRICS_OTLP_HTTP_TLS_INSECURESKIPVERIFY`:
TLS insecure skip verify (Default: ```false```)
`TRAEFIK_METRICS_OTLP_HTTP_TLS_KEY`:
TLS key
`TRAEFIK_METRICS_OTLP_PUSHINTERVAL`:
Period between calls to collect a checkpoint. (Default: ```10```)
`TRAEFIK_METRICS_PROMETHEUS`: `TRAEFIK_METRICS_PROMETHEUS`:
Prometheus metrics exporter type. (Default: ```false```) Prometheus metrics exporter type. (Default: ```false```)
@ -1005,15 +1017,15 @@ Enables tracing for internal services (ping, dashboard, etc...). (Default: ```fa
`TRAEFIK_TRACING_GLOBALATTRIBUTES_<NAME>`: `TRAEFIK_TRACING_GLOBALATTRIBUTES_<NAME>`:
Defines additional attributes (key:value) on all spans. Defines additional attributes (key:value) on all spans.
`TRAEFIK_TRACING_HEADERS_<NAME>`:
Defines additional headers to be sent with the payloads.
`TRAEFIK_TRACING_OTLP`: `TRAEFIK_TRACING_OTLP`:
Settings for OpenTelemetry. (Default: ```false```) Settings for OpenTelemetry. (Default: ```false```)
`TRAEFIK_TRACING_OTLP_GRPC_ENDPOINT`: `TRAEFIK_TRACING_OTLP_GRPC_ENDPOINT`:
Sets the gRPC endpoint (host:port) of the collector. (Default: ```localhost:4317```) Sets the gRPC endpoint (host:port) of the collector. (Default: ```localhost:4317```)
`TRAEFIK_TRACING_OTLP_GRPC_HEADERS_<NAME>`:
Headers sent with payload.
`TRAEFIK_TRACING_OTLP_GRPC_INSECURE`: `TRAEFIK_TRACING_OTLP_GRPC_INSECURE`:
Disables client transport security for the exporter. (Default: ```false```) Disables client transport security for the exporter. (Default: ```false```)
@ -1030,7 +1042,10 @@ TLS insecure skip verify (Default: ```false```)
TLS key TLS key
`TRAEFIK_TRACING_OTLP_HTTP_ENDPOINT`: `TRAEFIK_TRACING_OTLP_HTTP_ENDPOINT`:
Sets the HTTP endpoint (scheme://host:port/v1/traces) of the collector. (Default: ```localhost:4318```) Sets the HTTP endpoint (scheme://host:port/path) of the collector. (Default: ```https://localhost:4318```)
`TRAEFIK_TRACING_OTLP_HTTP_HEADERS_<NAME>`:
Headers sent with payload.
`TRAEFIK_TRACING_OTLP_HTTP_TLS_CA`: `TRAEFIK_TRACING_OTLP_HTTP_TLS_CA`:
TLS CA TLS CA

View file

@ -314,24 +314,33 @@
[metrics.influxDB2.additionalLabels] [metrics.influxDB2.additionalLabels]
name0 = "foobar" name0 = "foobar"
name1 = "foobar" name1 = "foobar"
[metrics.openTelemetry] [metrics.otlp]
address = "foobar"
addEntryPointsLabels = true addEntryPointsLabels = true
addRoutersLabels = true addRoutersLabels = true
addServicesLabels = true addServicesLabels = true
explicitBoundaries = [42.0, 42.0] explicitBoundaries = [42.0, 42.0]
insecure = true
path = "foobar"
pushInterval = "42s" pushInterval = "42s"
[metrics.openTelemetry.grpc] [metrics.otlp.grpc]
[metrics.openTelemetry.headers] endpoint = "foobar"
name0 = "foobar" insecure = true
name1 = "foobar" [metrics.otlp.grpc.tls]
[metrics.openTelemetry.tls]
ca = "foobar" ca = "foobar"
cert = "foobar" cert = "foobar"
key = "foobar" key = "foobar"
insecureSkipVerify = true insecureSkipVerify = true
[metrics.otlp.grpc.headers]
name0 = "foobar"
name1 = "foobar"
[metrics.otlp.http]
endpoint = "foobar"
[metrics.otlp.http.tls]
ca = "foobar"
cert = "foobar"
key = "foobar"
insecureSkipVerify = true
[metrics.otlp.http.headers]
name0 = "foobar"
name1 = "foobar"
[ping] [ping]
entryPoint = "foobar" entryPoint = "foobar"
@ -372,9 +381,6 @@
serviceName = "foobar" serviceName = "foobar"
sampleRate = 42.0 sampleRate = 42.0
addInternals = true addInternals = true
[tracing.headers]
name0 = "foobar"
name1 = "foobar"
[tracing.globalAttributes] [tracing.globalAttributes]
name0 = "foobar" name0 = "foobar"
name1 = "foobar" name1 = "foobar"
@ -387,6 +393,9 @@
cert = "foobar" cert = "foobar"
key = "foobar" key = "foobar"
insecureSkipVerify = true insecureSkipVerify = true
[tracing.otlp.grpc.headers]
name0 = "foobar"
name1 = "foobar"
[tracing.otlp.http] [tracing.otlp.http]
endpoint = "foobar" endpoint = "foobar"
[tracing.otlp.http.tls] [tracing.otlp.http.tls]
@ -394,6 +403,9 @@
cert = "foobar" cert = "foobar"
key = "foobar" key = "foobar"
insecureSkipVerify = true insecureSkipVerify = true
[tracing.otlp.http.headers]
name0 = "foobar"
name1 = "foobar"
[hostResolver] [hostResolver]
cnameFlattening = true cnameFlattening = true

View file

@ -347,26 +347,35 @@ metrics:
additionalLabels: additionalLabels:
name0: foobar name0: foobar
name1: foobar name1: foobar
openTelemetry: otlp:
grpc: {} grpc:
address: foobar endpoint: foobar
insecure: true
tls:
ca: foobar
cert: foobar
key: foobar
insecureSkipVerify: true
headers:
name0: foobar
name1: foobar
http:
endpoint: foobar
tls:
ca: foobar
cert: foobar
key: foobar
insecureSkipVerify: true
headers:
name0: foobar
name1: foobar
addEntryPointsLabels: true addEntryPointsLabels: true
addRoutersLabels: true addRoutersLabels: true
addServicesLabels: true addServicesLabels: true
explicitBoundaries: explicitBoundaries:
- 42 - 42
- 42 - 42
headers:
name0: foobar
name1: foobar
insecure: true
path: foobar
pushInterval: 42s pushInterval: 42s
tls:
ca: foobar
cert: foobar
key: foobar
insecureSkipVerify: true
ping: ping:
entryPoint: foobar entryPoint: foobar
manualRouting: true manualRouting: true
@ -403,9 +412,6 @@ accessLog:
addInternals: true addInternals: true
tracing: tracing:
serviceName: foobar serviceName: foobar
headers:
name0: foobar
name1: foobar
globalAttributes: globalAttributes:
name0: foobar name0: foobar
name1: foobar name1: foobar
@ -420,6 +426,9 @@ tracing:
cert: foobar cert: foobar
key: foobar key: foobar
insecureSkipVerify: true insecureSkipVerify: true
headers:
name0: foobar
name1: foobar
http: http:
endpoint: foobar endpoint: foobar
tls: tls:
@ -427,6 +436,9 @@ tracing:
cert: foobar cert: foobar
key: foobar key: foobar
insecureSkipVerify: true insecureSkipVerify: true
headers:
name0: foobar
name1: foobar
hostResolver: hostResolver:
cnameFlattening: true cnameFlattening: true
resolvConfig: foobar resolvConfig: foobar

View file

@ -194,7 +194,6 @@ func (a *LifeCycle) SetDefaults() {
// Tracing holds the tracing configuration. // Tracing holds the tracing configuration.
type Tracing struct { type Tracing struct {
ServiceName string `description:"Set the name for this service." json:"serviceName,omitempty" toml:"serviceName,omitempty" yaml:"serviceName,omitempty" export:"true"` ServiceName string `description:"Set the name for this service." json:"serviceName,omitempty" toml:"serviceName,omitempty" yaml:"serviceName,omitempty" export:"true"`
Headers map[string]string `description:"Defines additional headers to be sent with the payloads." json:"headers,omitempty" toml:"headers,omitempty" yaml:"headers,omitempty" export:"true"`
GlobalAttributes map[string]string `description:"Defines additional attributes (key:value) on all spans." json:"globalAttributes,omitempty" toml:"globalAttributes,omitempty" yaml:"globalAttributes,omitempty" export:"true"` GlobalAttributes map[string]string `description:"Defines additional attributes (key:value) on all spans." json:"globalAttributes,omitempty" toml:"globalAttributes,omitempty" yaml:"globalAttributes,omitempty" export:"true"`
SampleRate float64 `description:"Sets the rate between 0.0 and 1.0 of requests to trace." json:"sampleRate,omitempty" toml:"sampleRate,omitempty" yaml:"sampleRate,omitempty" export:"true"` SampleRate float64 `description:"Sets the rate between 0.0 and 1.0 of requests to trace." json:"sampleRate,omitempty" toml:"sampleRate,omitempty" yaml:"sampleRate,omitempty" export:"true"`
AddInternals bool `description:"Enables tracing for internal services (ping, dashboard, etc...)." json:"addInternals,omitempty" toml:"addInternals,omitempty" yaml:"addInternals,omitempty" export:"true"` AddInternals bool `description:"Enables tracing for internal services (ping, dashboard, etc...)." json:"addInternals,omitempty" toml:"addInternals,omitempty" yaml:"addInternals,omitempty" export:"true"`
@ -342,19 +341,17 @@ func (c *Configuration) ValidateConfiguration() error {
} }
if c.Tracing != nil && c.Tracing.OTLP != nil { if c.Tracing != nil && c.Tracing.OTLP != nil {
if c.Tracing.OTLP.HTTP == nil && c.Tracing.OTLP.GRPC == nil {
return errors.New("tracing OTLP: at least one of HTTP and gRPC options should be defined")
}
if c.Tracing.OTLP.HTTP != nil && c.Tracing.OTLP.GRPC != nil {
return errors.New("tracing OTLP: HTTP and gRPC options are mutually exclusive")
}
if c.Tracing.OTLP.GRPC != nil && c.Tracing.OTLP.GRPC.TLS != nil && c.Tracing.OTLP.GRPC.Insecure { if c.Tracing.OTLP.GRPC != nil && c.Tracing.OTLP.GRPC.TLS != nil && c.Tracing.OTLP.GRPC.Insecure {
return errors.New("tracing OTLP GRPC: TLS and Insecure options are mutually exclusive") return errors.New("tracing OTLP GRPC: TLS and Insecure options are mutually exclusive")
} }
} }
if c.Metrics != nil && c.Metrics.OTLP != nil {
if c.Metrics.OTLP.GRPC != nil && c.Metrics.OTLP.GRPC.TLS != nil && c.Metrics.OTLP.GRPC.Insecure {
return errors.New("metrics OTLP GRPC: TLS and Insecure options are mutually exclusive")
}
}
return nil return nil
} }

View file

@ -4,6 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"net" "net"
"net/url"
"strings" "strings"
"sync" "sync"
"time" "time"
@ -30,7 +31,7 @@ var (
) )
// RegisterOpenTelemetry registers all OpenTelemetry metrics. // RegisterOpenTelemetry registers all OpenTelemetry metrics.
func RegisterOpenTelemetry(ctx context.Context, config *types.OpenTelemetry) Registry { func RegisterOpenTelemetry(ctx context.Context, config *types.OTLP) Registry {
if openTelemetryMeterProvider == nil { if openTelemetryMeterProvider == nil {
var err error var err error
if openTelemetryMeterProvider, err = newOpenTelemetryMeterProvider(ctx, config); err != nil { if openTelemetryMeterProvider, err = newOpenTelemetryMeterProvider(ctx, config); err != nil {
@ -123,15 +124,15 @@ func StopOpenTelemetry() {
} }
// newOpenTelemetryMeterProvider creates a new controller.Controller. // newOpenTelemetryMeterProvider creates a new controller.Controller.
func newOpenTelemetryMeterProvider(ctx context.Context, config *types.OpenTelemetry) (*sdkmetric.MeterProvider, error) { func newOpenTelemetryMeterProvider(ctx context.Context, config *types.OTLP) (*sdkmetric.MeterProvider, error) {
var ( var (
exporter sdkmetric.Exporter exporter sdkmetric.Exporter
err error err error
) )
if config.GRPC != nil { if config.GRPC != nil {
exporter, err = newGRPCExporter(ctx, config) exporter, err = newGRPCExporter(ctx, config.GRPC)
} else { } else {
exporter, err = newHTTPExporter(ctx, config) exporter, err = newHTTPExporter(ctx, config.HTTP)
} }
if err != nil { if err != nil {
return nil, fmt.Errorf("creating exporter: %w", err) return nil, fmt.Errorf("creating exporter: %w", err)
@ -168,24 +169,24 @@ func newOpenTelemetryMeterProvider(ctx context.Context, config *types.OpenTeleme
return meterProvider, nil return meterProvider, nil
} }
func newHTTPExporter(ctx context.Context, config *types.OpenTelemetry) (sdkmetric.Exporter, error) { func newHTTPExporter(ctx context.Context, config *types.OtelHTTP) (sdkmetric.Exporter, error) {
host, port, err := net.SplitHostPort(config.Address) endpoint, err := url.Parse(config.Endpoint)
if err != nil { if err != nil {
return nil, fmt.Errorf("invalid collector address %q: %w", config.Address, err) return nil, fmt.Errorf("invalid collector endpoint %q: %w", config.Endpoint, err)
} }
opts := []otlpmetrichttp.Option{ opts := []otlpmetrichttp.Option{
otlpmetrichttp.WithEndpoint(fmt.Sprintf("%s:%s", host, port)), otlpmetrichttp.WithEndpoint(endpoint.Host),
otlpmetrichttp.WithHeaders(config.Headers), otlpmetrichttp.WithHeaders(config.Headers),
otlpmetrichttp.WithCompression(otlpmetrichttp.GzipCompression), otlpmetrichttp.WithCompression(otlpmetrichttp.GzipCompression),
} }
if config.Insecure { if endpoint.Scheme == "http" {
opts = append(opts, otlpmetrichttp.WithInsecure()) opts = append(opts, otlpmetrichttp.WithInsecure())
} }
if config.Path != "" { if endpoint.Path != "" {
opts = append(opts, otlpmetrichttp.WithURLPath(config.Path)) opts = append(opts, otlpmetrichttp.WithURLPath(endpoint.Path))
} }
if config.TLS != nil { if config.TLS != nil {
@ -200,10 +201,10 @@ func newHTTPExporter(ctx context.Context, config *types.OpenTelemetry) (sdkmetri
return otlpmetrichttp.New(ctx, opts...) return otlpmetrichttp.New(ctx, opts...)
} }
func newGRPCExporter(ctx context.Context, config *types.OpenTelemetry) (sdkmetric.Exporter, error) { func newGRPCExporter(ctx context.Context, config *types.OtelGRPC) (sdkmetric.Exporter, error) {
host, port, err := net.SplitHostPort(config.Address) host, port, err := net.SplitHostPort(config.Endpoint)
if err != nil { if err != nil {
return nil, fmt.Errorf("invalid collector address %q: %w", config.Address, err) return nil, fmt.Errorf("invalid collector endpoint %q: %w", config.Endpoint, err)
} }
opts := []otlpmetricgrpc.Option{ opts := []otlpmetricgrpc.Option{

View file

@ -8,7 +8,6 @@ import (
"io" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"net/url"
"regexp" "regexp"
"strconv" "strconv"
"testing" "testing"
@ -316,14 +315,12 @@ func TestOpenTelemetry(t *testing.T) {
ts.Close() ts.Close()
}) })
sURL, err := url.Parse(ts.URL) var cfg types.OTLP
require.NoError(t, err)
var cfg types.OpenTelemetry
(&cfg).SetDefaults() (&cfg).SetDefaults()
cfg.AddRoutersLabels = true cfg.AddRoutersLabels = true
cfg.Address = sURL.Host cfg.HTTP = &types.OtelHTTP{
cfg.Insecure = true Endpoint: ts.URL,
}
cfg.PushInterval = ptypes.Duration(10 * time.Millisecond) cfg.PushInterval = ptypes.Duration(10 * time.Millisecond)
registry := RegisterOpenTelemetry(context.Background(), &cfg) registry := RegisterOpenTelemetry(context.Background(), &cfg)

View file

@ -17,6 +17,7 @@ import (
"github.com/traefik/traefik/v3/pkg/testhelpers" "github.com/traefik/traefik/v3/pkg/testhelpers"
"github.com/traefik/traefik/v3/pkg/tracing" "github.com/traefik/traefik/v3/pkg/tracing"
"github.com/traefik/traefik/v3/pkg/tracing/opentelemetry" "github.com/traefik/traefik/v3/pkg/tracing/opentelemetry"
"github.com/traefik/traefik/v3/pkg/types"
"github.com/traefik/traefik/v3/pkg/version" "github.com/traefik/traefik/v3/pkg/version"
"github.com/vulcand/oxy/v2/forward" "github.com/vulcand/oxy/v2/forward"
"go.opentelemetry.io/otel" "go.opentelemetry.io/otel"
@ -500,7 +501,7 @@ func TestForwardAuthUsesTracing(t *testing.T) {
ServiceName: "testApp", ServiceName: "testApp",
SampleRate: 1, SampleRate: 1,
OTLP: &opentelemetry.Config{ OTLP: &opentelemetry.Config{
HTTP: &opentelemetry.HTTP{ HTTP: &types.OtelHTTP{
Endpoint: "http://127.0.0.1:8080", Endpoint: "http://127.0.0.1:8080",
}, },
}, },

View file

@ -6,8 +6,10 @@ import (
"errors" "errors"
"fmt" "fmt"
"os" "os"
"os/signal"
"path/filepath" "path/filepath"
"strings" "strings"
"syscall"
"text/template" "text/template"
"github.com/Masterminds/sprig/v3" "github.com/Masterminds/sprig/v3"
@ -48,6 +50,8 @@ func (p *Provider) Init() error {
// Provide allows the file provider to provide configurations to traefik // Provide allows the file provider to provide configurations to traefik
// using the given configuration channel. // using the given configuration channel.
func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.Pool) error { func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.Pool) error {
logger := log.With().Str(logs.ProviderName, providerName).Logger()
if p.Watch { if p.Watch {
var watchItem string var watchItem string
@ -57,48 +61,44 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
case len(p.Filename) > 0: case len(p.Filename) > 0:
watchItem = filepath.Dir(p.Filename) watchItem = filepath.Dir(p.Filename)
default: default:
return errors.New("error using file configuration provider, neither filename or directory defined") return errors.New("error using file configuration provider, neither filename nor directory is defined")
} }
if err := p.addWatcher(pool, watchItem, configurationChan, p.watcherCallback); err != nil { if err := p.addWatcher(pool, watchItem, configurationChan, p.applyConfiguration); err != nil {
return err return err
} }
} }
configuration, err := p.BuildConfiguration() pool.GoCtx(func(ctx context.Context) {
if err != nil { signals := make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGHUP)
for {
select {
case <-ctx.Done():
return
// signals only receives SIGHUP events.
case <-signals:
if err := p.applyConfiguration(configurationChan); err != nil {
logger.Error().Err(err).Msg("Error while building configuration")
}
}
}
})
if err := p.applyConfiguration(configurationChan); err != nil {
if p.Watch { if p.Watch {
log.Error(). logger.Err(err).Msg("Error while building configuration (for the first time)")
Str(logs.ProviderName, providerName).
Err(err).
Msg("Error while building configuration (for the first time)")
return nil return nil
} }
return err return err
} }
sendConfigToChannel(configurationChan, configuration)
return nil return nil
} }
// BuildConfiguration loads configuration either from file or a directory func (p *Provider) addWatcher(pool *safe.Pool, directory string, configurationChan chan<- dynamic.Message, callback func(chan<- dynamic.Message) error) error {
// specified by 'Filename'/'Directory' and returns a 'Configuration' object.
func (p *Provider) BuildConfiguration() (*dynamic.Configuration, error) {
ctx := log.With().Str(logs.ProviderName, providerName).Logger().WithContext(context.Background())
if len(p.Directory) > 0 {
return p.loadFileConfigFromDirectory(ctx, p.Directory, nil)
}
if len(p.Filename) > 0 {
return p.loadFileConfig(ctx, p.Filename, true)
}
return nil, errors.New("error using file configuration provider, neither filename or directory defined")
}
func (p *Provider) addWatcher(pool *safe.Pool, directory string, configurationChan chan<- dynamic.Message, callback func(chan<- dynamic.Message, fsnotify.Event)) error {
watcher, err := fsnotify.NewWatcher() watcher, err := fsnotify.NewWatcher()
if err != nil { if err != nil {
return fmt.Errorf("error creating file watcher: %w", err) return fmt.Errorf("error creating file watcher: %w", err)
@ -111,6 +111,7 @@ func (p *Provider) addWatcher(pool *safe.Pool, directory string, configurationCh
// Process events // Process events
pool.GoCtx(func(ctx context.Context) { pool.GoCtx(func(ctx context.Context) {
logger := log.With().Str(logs.ProviderName, providerName).Logger()
defer watcher.Close() defer watcher.Close()
for { for {
select { select {
@ -121,39 +122,50 @@ func (p *Provider) addWatcher(pool *safe.Pool, directory string, configurationCh
_, evtFileName := filepath.Split(evt.Name) _, evtFileName := filepath.Split(evt.Name)
_, confFileName := filepath.Split(p.Filename) _, confFileName := filepath.Split(p.Filename)
if evtFileName == confFileName { if evtFileName == confFileName {
callback(configurationChan, evt) err := callback(configurationChan)
if err != nil {
logger.Error().Err(err).Msg("Error occurred during watcher callback")
}
} }
} else { } else {
callback(configurationChan, evt) err := callback(configurationChan)
if err != nil {
logger.Error().Err(err).Msg("Error occurred during watcher callback")
}
} }
case err := <-watcher.Errors: case err := <-watcher.Errors:
log.Error().Str(logs.ProviderName, providerName).Err(err).Msg("Watcher event error") logger.Error().Err(err).Msg("Watcher event error")
} }
} }
}) })
return nil return nil
} }
func (p *Provider) watcherCallback(configurationChan chan<- dynamic.Message, event fsnotify.Event) { // applyConfiguration builds the configuration and sends it to the given configurationChan.
watchItem := p.Filename func (p *Provider) applyConfiguration(configurationChan chan<- dynamic.Message) error {
if len(p.Directory) > 0 { configuration, err := p.buildConfiguration()
watchItem = p.Directory
}
logger := log.With().Str(logs.ProviderName, providerName).Logger()
if _, err := os.Stat(watchItem); err != nil {
logger.Error().Err(err).Msgf("Unable to watch %s", watchItem)
return
}
configuration, err := p.BuildConfiguration()
if err != nil { if err != nil {
logger.Error().Err(err).Msg("Error occurred during watcher callback") return err
return
} }
sendConfigToChannel(configurationChan, configuration) sendConfigToChannel(configurationChan, configuration)
return nil
}
// buildConfiguration loads configuration either from file or a directory
// specified by 'Filename'/'Directory' and returns a 'Configuration' object.
func (p *Provider) buildConfiguration() (*dynamic.Configuration, error) {
ctx := log.With().Str(logs.ProviderName, providerName).Logger().WithContext(context.Background())
if len(p.Directory) > 0 {
return p.loadFileConfigFromDirectory(ctx, p.Directory, nil)
}
if len(p.Filename) > 0 {
return p.loadFileConfig(ctx, p.Filename, true)
}
return nil, errors.New("error using file configuration provider, neither filename nor directory is defined")
} }
func sendConfigToChannel(configurationChan chan<- dynamic.Message, configuration *dynamic.Configuration) { func sendConfigToChannel(configurationChan chan<- dynamic.Message, configuration *dynamic.Configuration) {

View file

@ -123,8 +123,6 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
logger := log.With().Str(logs.ProviderName, providerName).Logger() logger := log.With().Str(logs.ProviderName, providerName).Logger()
ctxLog := logger.WithContext(context.Background()) ctxLog := logger.WithContext(context.Background())
logger.Warn().Msg("CRDs API Version \"traefik.io/v1alpha1\" will not be supported in Traefik v3 itself. However, an automatic migration path to the next version will be available.")
k8sClient, err := p.newK8sClient(ctxLog) k8sClient, err := p.newK8sClient(ctxLog)
if err != nil { if err != nil {
return err return err

View file

@ -846,17 +846,17 @@ func TestDo_staticConfiguration(t *testing.T) {
config.Tracing = &static.Tracing{ config.Tracing = &static.Tracing{
ServiceName: "myServiceName", ServiceName: "myServiceName",
Headers: map[string]string{
"foobar": "foobar",
},
GlobalAttributes: map[string]string{ GlobalAttributes: map[string]string{
"foobar": "foobar", "foobar": "foobar",
}, },
SampleRate: 42, SampleRate: 42,
OTLP: &opentelemetry.Config{ OTLP: &opentelemetry.Config{
HTTP: &opentelemetry.HTTP{ HTTP: &types.OtelHTTP{
Endpoint: "foobar", Endpoint: "foobar",
TLS: nil, TLS: nil,
Headers: map[string]string{
"foobar": "foobar",
},
}, },
}, },
} }

View file

@ -344,9 +344,6 @@
}, },
"tracing": { "tracing": {
"serviceName": "myServiceName", "serviceName": "myServiceName",
"headers": {
"foobar": "foobar"
},
"globalAttributes": { "globalAttributes": {
"foobar": "foobar" "foobar": "foobar"
}, },

View file

@ -27,44 +27,26 @@ import (
// Config provides configuration settings for the open-telemetry tracer. // Config provides configuration settings for the open-telemetry tracer.
type Config struct { type Config struct {
GRPC *GRPC `description:"gRPC configuration for the OpenTelemetry collector." json:"grpc,omitempty" toml:"grpc,omitempty" yaml:"grpc,omitempty" export:"true"` GRPC *types.OtelGRPC `description:"gRPC configuration for the OpenTelemetry collector." json:"grpc,omitempty" toml:"grpc,omitempty" yaml:"grpc,omitempty" export:"true"`
HTTP *HTTP `description:"HTTP configuration for the OpenTelemetry collector." json:"http,omitempty" toml:"http,omitempty" yaml:"http,omitempty" export:"true"` HTTP *types.OtelHTTP `description:"HTTP configuration for the OpenTelemetry collector." json:"http,omitempty" toml:"http,omitempty" yaml:"http,omitempty" export:"true"`
}
// GRPC provides configuration settings for the gRPC open-telemetry tracer.
type GRPC struct {
Endpoint string `description:"Sets the gRPC endpoint (host:port) of the collector." json:"endpoint,omitempty" toml:"endpoint,omitempty" yaml:"endpoint,omitempty"`
Insecure bool `description:"Disables client transport security for the exporter." json:"insecure,omitempty" toml:"insecure,omitempty" yaml:"insecure,omitempty" export:"true"`
TLS *types.ClientTLS `description:"Defines client transport security parameters." json:"tls,omitempty" toml:"tls,omitempty" yaml:"tls,omitempty" export:"true"`
} }
// SetDefaults sets the default values. // SetDefaults sets the default values.
func (c *GRPC) SetDefaults() { func (c *Config) SetDefaults() {
c.Endpoint = "localhost:4317" c.HTTP = &types.OtelHTTP{}
} c.HTTP.SetDefaults()
// HTTP provides configuration settings for the HTTP open-telemetry tracer.
type HTTP struct {
Endpoint string `description:"Sets the HTTP endpoint (scheme://host:port/v1/traces) of the collector." json:"endpoint,omitempty" toml:"endpoint,omitempty" yaml:"endpoint,omitempty"`
TLS *types.ClientTLS `description:"Defines client transport security parameters." json:"tls,omitempty" toml:"tls,omitempty" yaml:"tls,omitempty" export:"true"`
}
// SetDefaults sets the default values.
func (c *HTTP) SetDefaults() {
c.Endpoint = "localhost:4318"
} }
// Setup sets up the tracer. // Setup sets up the tracer.
func (c *Config) Setup(serviceName string, sampleRate float64, globalAttributes map[string]string, headers map[string]string) (trace.Tracer, io.Closer, error) { func (c *Config) Setup(serviceName string, sampleRate float64, globalAttributes map[string]string) (trace.Tracer, io.Closer, error) {
var ( var (
err error err error
exporter *otlptrace.Exporter exporter *otlptrace.Exporter
) )
if c.GRPC != nil { if c.GRPC != nil {
exporter, err = c.setupGRPCExporter(headers) exporter, err = c.setupGRPCExporter()
} else { } else {
exporter, err = c.setupHTTPExporter(headers) exporter, err = c.setupHTTPExporter()
} }
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("setting up exporter: %w", err) return nil, nil, fmt.Errorf("setting up exporter: %w", err)
@ -107,7 +89,7 @@ func (c *Config) Setup(serviceName string, sampleRate float64, globalAttributes
return tracerProvider.Tracer("github.com/traefik/traefik"), &tpCloser{provider: tracerProvider}, err return tracerProvider.Tracer("github.com/traefik/traefik"), &tpCloser{provider: tracerProvider}, err
} }
func (c *Config) setupHTTPExporter(headers map[string]string) (*otlptrace.Exporter, error) { func (c *Config) setupHTTPExporter() (*otlptrace.Exporter, error) {
endpoint, err := url.Parse(c.HTTP.Endpoint) endpoint, err := url.Parse(c.HTTP.Endpoint)
if err != nil { if err != nil {
return nil, fmt.Errorf("invalid collector endpoint %q: %w", c.HTTP.Endpoint, err) return nil, fmt.Errorf("invalid collector endpoint %q: %w", c.HTTP.Endpoint, err)
@ -115,7 +97,7 @@ func (c *Config) setupHTTPExporter(headers map[string]string) (*otlptrace.Export
opts := []otlptracehttp.Option{ opts := []otlptracehttp.Option{
otlptracehttp.WithEndpoint(endpoint.Host), otlptracehttp.WithEndpoint(endpoint.Host),
otlptracehttp.WithHeaders(headers), otlptracehttp.WithHeaders(c.HTTP.Headers),
otlptracehttp.WithCompression(otlptracehttp.GzipCompression), otlptracehttp.WithCompression(otlptracehttp.GzipCompression),
} }
@ -139,15 +121,15 @@ func (c *Config) setupHTTPExporter(headers map[string]string) (*otlptrace.Export
return otlptrace.New(context.Background(), otlptracehttp.NewClient(opts...)) return otlptrace.New(context.Background(), otlptracehttp.NewClient(opts...))
} }
func (c *Config) setupGRPCExporter(headers map[string]string) (*otlptrace.Exporter, error) { func (c *Config) setupGRPCExporter() (*otlptrace.Exporter, error) {
host, port, err := net.SplitHostPort(c.GRPC.Endpoint) host, port, err := net.SplitHostPort(c.GRPC.Endpoint)
if err != nil { if err != nil {
return nil, fmt.Errorf("invalid collector address %q: %w", c.GRPC.Endpoint, err) return nil, fmt.Errorf("invalid collector endpoint %q: %w", c.GRPC.Endpoint, err)
} }
opts := []otlptracegrpc.Option{ opts := []otlptracegrpc.Option{
otlptracegrpc.WithEndpoint(fmt.Sprintf("%s:%s", host, port)), otlptracegrpc.WithEndpoint(fmt.Sprintf("%s:%s", host, port)),
otlptracegrpc.WithHeaders(headers), otlptracegrpc.WithHeaders(c.GRPC.Headers),
otlptracegrpc.WithCompressor(gzip.Name), otlptracegrpc.WithCompressor(gzip.Name),
} }

View file

@ -17,6 +17,7 @@ import (
tracingMiddle "github.com/traefik/traefik/v3/pkg/middlewares/tracing" tracingMiddle "github.com/traefik/traefik/v3/pkg/middlewares/tracing"
"github.com/traefik/traefik/v3/pkg/tracing" "github.com/traefik/traefik/v3/pkg/tracing"
"github.com/traefik/traefik/v3/pkg/tracing/opentelemetry" "github.com/traefik/traefik/v3/pkg/tracing/opentelemetry"
"github.com/traefik/traefik/v3/pkg/types"
"go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" "go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp"
) )
@ -74,7 +75,7 @@ func TestTracing(t *testing.T) {
ServiceName: "traefik", ServiceName: "traefik",
SampleRate: 1.0, SampleRate: 1.0,
OTLP: &opentelemetry.Config{ OTLP: &opentelemetry.Config{
HTTP: &opentelemetry.HTTP{ HTTP: &types.OtelHTTP{
Endpoint: collector.URL, Endpoint: collector.URL,
}, },
}, },

View file

@ -20,7 +20,7 @@ import (
// Backend is an abstraction for tracking backend (OpenTelemetry, ...). // Backend is an abstraction for tracking backend (OpenTelemetry, ...).
type Backend interface { type Backend interface {
Setup(serviceName string, sampleRate float64, globalAttributes map[string]string, headers map[string]string) (trace.Tracer, io.Closer, error) Setup(serviceName string, sampleRate float64, globalAttributes map[string]string) (trace.Tracer, io.Closer, error)
} }
// NewTracing Creates a Tracing. // NewTracing Creates a Tracing.
@ -37,7 +37,7 @@ func NewTracing(conf *static.Tracing) (trace.Tracer, io.Closer, error) {
backend = defaultBackend backend = defaultBackend
} }
return backend.Setup(conf.ServiceName, conf.SampleRate, conf.GlobalAttributes, conf.Headers) return backend.Setup(conf.ServiceName, conf.SampleRate, conf.GlobalAttributes)
} }
// TracerFromContext extracts the trace.Tracer from the given context. // TracerFromContext extracts the trace.Tracer from the given context.

View file

@ -16,7 +16,7 @@ type Metrics struct {
Datadog *Datadog `description:"Datadog metrics exporter type." json:"datadog,omitempty" toml:"datadog,omitempty" yaml:"datadog,omitempty" label:"allowEmpty" file:"allowEmpty" export:"true"` Datadog *Datadog `description:"Datadog metrics exporter type." json:"datadog,omitempty" toml:"datadog,omitempty" yaml:"datadog,omitempty" label:"allowEmpty" file:"allowEmpty" export:"true"`
StatsD *Statsd `description:"StatsD metrics exporter type." json:"statsD,omitempty" toml:"statsD,omitempty" yaml:"statsD,omitempty" label:"allowEmpty" file:"allowEmpty" export:"true"` StatsD *Statsd `description:"StatsD metrics exporter type." json:"statsD,omitempty" toml:"statsD,omitempty" yaml:"statsD,omitempty" label:"allowEmpty" file:"allowEmpty" export:"true"`
InfluxDB2 *InfluxDB2 `description:"InfluxDB v2 metrics exporter type." json:"influxDB2,omitempty" toml:"influxDB2,omitempty" yaml:"influxDB2,omitempty" label:"allowEmpty" file:"allowEmpty" export:"true"` InfluxDB2 *InfluxDB2 `description:"InfluxDB v2 metrics exporter type." json:"influxDB2,omitempty" toml:"influxDB2,omitempty" yaml:"influxDB2,omitempty" label:"allowEmpty" file:"allowEmpty" export:"true"`
OpenTelemetry *OpenTelemetry `description:"OpenTelemetry metrics exporter type." json:"openTelemetry,omitempty" toml:"openTelemetry,omitempty" yaml:"openTelemetry,omitempty" label:"allowEmpty" file:"allowEmpty" export:"true"` OTLP *OTLP `description:"OpenTelemetry metrics exporter type." json:"otlp,omitempty" toml:"otlp,omitempty" yaml:"otlp,omitempty" label:"allowEmpty" file:"allowEmpty" export:"true"`
} }
// Prometheus can contain specific configuration used by the Prometheus Metrics exporter. // Prometheus can contain specific configuration used by the Prometheus Metrics exporter.
@ -106,26 +106,23 @@ func (i *InfluxDB2) SetDefaults() {
i.AddServicesLabels = true i.AddServicesLabels = true
} }
// OpenTelemetry contains specific configuration used by the OpenTelemetry Metrics exporter. // OTLP contains specific configuration used by the OpenTelemetry Metrics exporter.
type OpenTelemetry struct { type OTLP struct {
// NOTE: as no gRPC option is implemented yet, the type is empty and is used as a boolean for upward compatibility purposes. GRPC *OtelGRPC `description:"gRPC configuration for the OpenTelemetry collector." json:"grpc,omitempty" toml:"grpc,omitempty" yaml:"grpc,omitempty" export:"true"`
GRPC *struct{} `description:"gRPC specific configuration for the OpenTelemetry collector." json:"grpc,omitempty" toml:"grpc,omitempty" yaml:"grpc,omitempty" label:"allowEmpty" file:"allowEmpty" export:"true"` HTTP *OtelHTTP `description:"HTTP configuration for the OpenTelemetry collector." json:"http,omitempty" toml:"http,omitempty" yaml:"http,omitempty" export:"true"`
Address string `description:"Address (host:port) of the collector endpoint." json:"address,omitempty" toml:"address,omitempty" yaml:"address,omitempty"`
AddEntryPointsLabels bool `description:"Enable metrics on entry points." json:"addEntryPointsLabels,omitempty" toml:"addEntryPointsLabels,omitempty" yaml:"addEntryPointsLabels,omitempty" export:"true"` AddEntryPointsLabels bool `description:"Enable metrics on entry points." json:"addEntryPointsLabels,omitempty" toml:"addEntryPointsLabels,omitempty" yaml:"addEntryPointsLabels,omitempty" export:"true"`
AddRoutersLabels bool `description:"Enable metrics on routers." json:"addRoutersLabels,omitempty" toml:"addRoutersLabels,omitempty" yaml:"addRoutersLabels,omitempty" export:"true"` AddRoutersLabels bool `description:"Enable metrics on routers." json:"addRoutersLabels,omitempty" toml:"addRoutersLabels,omitempty" yaml:"addRoutersLabels,omitempty" export:"true"`
AddServicesLabels bool `description:"Enable metrics on services." json:"addServicesLabels,omitempty" toml:"addServicesLabels,omitempty" yaml:"addServicesLabels,omitempty" export:"true"` AddServicesLabels bool `description:"Enable metrics on services." json:"addServicesLabels,omitempty" toml:"addServicesLabels,omitempty" yaml:"addServicesLabels,omitempty" export:"true"`
ExplicitBoundaries []float64 `description:"Boundaries for latency metrics." json:"explicitBoundaries,omitempty" toml:"explicitBoundaries,omitempty" yaml:"explicitBoundaries,omitempty" export:"true"` ExplicitBoundaries []float64 `description:"Boundaries for latency metrics." json:"explicitBoundaries,omitempty" toml:"explicitBoundaries,omitempty" yaml:"explicitBoundaries,omitempty" export:"true"`
Headers map[string]string `description:"Headers sent with payload." json:"headers,omitempty" toml:"headers,omitempty" yaml:"headers,omitempty" export:"true"`
Insecure bool `description:"Disables client transport security for the exporter." json:"insecure,omitempty" toml:"insecure,omitempty" yaml:"insecure,omitempty" export:"true"`
Path string `description:"Set the URL path of the collector endpoint." json:"path,omitempty" toml:"path,omitempty" yaml:"path,omitempty" export:"true"`
PushInterval types.Duration `description:"Period between calls to collect a checkpoint." json:"pushInterval,omitempty" toml:"pushInterval,omitempty" yaml:"pushInterval,omitempty" export:"true"` PushInterval types.Duration `description:"Period between calls to collect a checkpoint." json:"pushInterval,omitempty" toml:"pushInterval,omitempty" yaml:"pushInterval,omitempty" export:"true"`
TLS *ClientTLS `description:"Enable TLS support." json:"tls,omitempty" toml:"tls,omitempty" yaml:"tls,omitempty" export:"true"`
} }
// SetDefaults sets the default values. // SetDefaults sets the default values.
func (o *OpenTelemetry) SetDefaults() { func (o *OTLP) SetDefaults() {
o.Address = "localhost:4318" o.HTTP = &OtelHTTP{}
o.HTTP.SetDefaults()
o.AddEntryPointsLabels = true o.AddEntryPointsLabels = true
o.AddServicesLabels = true o.AddServicesLabels = true
o.ExplicitBoundaries = []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10} o.ExplicitBoundaries = []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10}
@ -141,3 +138,28 @@ type Statistics struct {
func (s *Statistics) SetDefaults() { func (s *Statistics) SetDefaults() {
s.RecentErrors = 10 s.RecentErrors = 10
} }
// OtelGRPC provides configuration settings for the gRPC open-telemetry.
type OtelGRPC struct {
Endpoint string `description:"Sets the gRPC endpoint (host:port) of the collector." json:"endpoint,omitempty" toml:"endpoint,omitempty" yaml:"endpoint,omitempty"`
Insecure bool `description:"Disables client transport security for the exporter." json:"insecure,omitempty" toml:"insecure,omitempty" yaml:"insecure,omitempty" export:"true"`
TLS *ClientTLS `description:"Defines client transport security parameters." json:"tls,omitempty" toml:"tls,omitempty" yaml:"tls,omitempty" export:"true"`
Headers map[string]string `description:"Headers sent with payload." json:"headers,omitempty" toml:"headers,omitempty" yaml:"headers,omitempty"`
}
// SetDefaults sets the default values.
func (c *OtelGRPC) SetDefaults() {
c.Endpoint = "localhost:4317"
}
// OtelHTTP provides configuration settings for the HTTP open-telemetry.
type OtelHTTP struct {
Endpoint string `description:"Sets the HTTP endpoint (scheme://host:port/path) of the collector." json:"endpoint,omitempty" toml:"endpoint,omitempty" yaml:"endpoint,omitempty"`
TLS *ClientTLS `description:"Defines client transport security parameters." json:"tls,omitempty" toml:"tls,omitempty" yaml:"tls,omitempty" export:"true"`
Headers map[string]string `description:"Headers sent with payload." json:"headers,omitempty" toml:"headers,omitempty" yaml:"headers,omitempty"`
}
// SetDefaults sets the default values.
func (c *OtelHTTP) SetDefaults() {
c.Endpoint = "https://localhost:4318"
}