Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Traefik Proxy): add tracingparameters to helm chart values #1271

Merged
merged 9 commits into from
Dec 10, 2024
27 changes: 27 additions & 0 deletions traefik/templates/_podtemplate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,33 @@
- "--tracing.addinternals"
{{- end }}

{{- with .Values.tracing }}
{{- with .sampleRate }}
- "--tracing.sampleRate={{ . }}"
{{- end }}

{{- with .serviceName }}
- "--tracing.serviceName={{ . }}"
{{- end }}

{{- range $name, $value := .globalAttributes }}
- "--tracing.globalAttributes.{{ $name }}={{ $value }}"
{{- end }}

{{- range $index, $value := .capturedRequestHeaders }}
- "--tracing.capturedRequestHeaders[{{ $index }}]={{ $value }}"
{{- end }}

{{- range $index, $value := .capturedResponseHeaders }}
- "--tracing.capturedResponseHeaders[{{ $index }}]={{ $value }}"
{{- end }}

{{- if .safeQueryParams }}
- "--tracing.safeQueryParams={{- .safeQueryParams | join "," -}}"
{{- end }}

{{- end }}

{{- with .Values.tracing.otlp }}
{{- if .enabled }}
- "--tracing.otlp=true"
Expand Down
4 changes: 4 additions & 0 deletions traefik/templates/requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@
{{- if and (semverCompare "<3.2.0-0" $version) (.Values.providers.kubernetesGateway.nativeLBByDefault)}}
{{- fail "ERROR: nativeLBByDefault has been introduced in Kubernetes Gateway provider in v3.2.0" }}
{{- end }}

{{- if and (semverCompare "<v3.1.0-0" $version) .Values.tracing.safeQueryParams }}
{{ fail "ERROR: safeQueryParams is a feature only available for traefik >= v3.1.0."}}
{{- end }}
10 changes: 10 additions & 0 deletions traefik/tests/requirements-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,13 @@ tests:
asserts:
- failedTemplate:
errorMessage: "ERROR: abortOnPluginFailure is an experimental feature only available for traefik >= v3.3.0."
- it: shouldn't have safeQueryParams, when enabled on traefik < 3.1.0
set:
image:
tag: v3.0.0
tracing:
safeQueryParams:
- foo
asserts:
- failedTemplate:
errorMessage: "ERROR: safeQueryParams is a feature only available for traefik >= v3.1.0."
33 changes: 33 additions & 0 deletions traefik/tests/tracing-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ tests:
set:
tracing:
addInternals: true
sampleRate: 0.5
serviceName: my-service-name
globalAttributes:
attr1: foo
attr2: bar
capturedRequestHeaders:
- X-CustomHeader
capturedResponseHeaders:
- X-CustomHeader
safeQueryParams:
- bar
- buz
otlp:
enabled: true
http:
Expand Down Expand Up @@ -38,6 +50,27 @@ tests:
- contains:
path: spec.template.spec.containers[0].args
content: "--tracing.addinternals"
- contains:
path: spec.template.spec.containers[0].args
content: "--tracing.sampleRate=0.5"
- contains:
path: spec.template.spec.containers[0].args
content: "--tracing.serviceName=my-service-name"
- contains:
path: spec.template.spec.containers[0].args
content: "--tracing.globalAttributes.attr1=foo"
- contains:
path: spec.template.spec.containers[0].args
content: "--tracing.globalAttributes.attr2=bar"
- contains:
path: spec.template.spec.containers[0].args
content: "--tracing.capturedRequestHeaders[0]=X-CustomHeader"
- contains:
path: spec.template.spec.containers[0].args
content: "--tracing.capturedResponseHeaders[0]=X-CustomHeader"
- contains:
path: spec.template.spec.containers[0].args
content: "--tracing.safeQueryParams=bar,buz"
- contains:
path: spec.template.spec.containers[0].args
content: "--tracing.otlp.http=true"
Expand Down
27 changes: 27 additions & 0 deletions traefik/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,16 @@
"addInternals": {
"type": "boolean"
},
"capturedRequestHeaders": {
"type": "array"
},
"capturedResponseHeaders": {
"type": "array"
},
"globalAttributes": {
"properties": {},
"type": "object"
},
"otlp": {
"properties": {
"enabled": {
Expand Down Expand Up @@ -1641,6 +1651,23 @@
}
},
"type": "object"
},
"safeQueryParams": {
"type": "array"
},
"sampleRate": {
"maximum": 1,
"minimum": 0,
"type": [
"number",
"null"
]
},
"serviceName": {
"type": [
"string",
"null"
]
}
},
"type": "object"
Expand Down
12 changes: 12 additions & 0 deletions traefik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,18 @@ metrics:
tracing: # @schema additionalProperties: false
# -- Enables tracing for internal resources. Default: false.
addInternals: false
# -- Service name used in selected backend. Default: traefik.
serviceName: # @schema type:[string, null]
# -- Applies a list of shared key:value attributes on all spans.
globalAttributes: {}
# -- Defines the list of request headers to add as attributes. It applies to client and server kind spans.
capturedRequestHeaders: []
# -- Defines the list of response headers to add as attributes. It applies to client and server kind spans.
capturedResponseHeaders: []
# -- By default, all query parameters are redacted. Defines the list of query parameters to not redact.
safeQueryParams: []
# -- The proportion of requests to trace, specified between 0.0 and 1.0. Default: 1.0.
sampleRate: # @schema type:[number, null]; minimum:0; maximum:1
otlp:
# -- See https://doc.traefik.io/traefik/v3.0/observability/tracing/opentelemetry/
enabled: false
Expand Down
Loading