Skip to content

Commit 7ff165c

Browse files
authored
feat: ✨ add hub tracing capabilities
1 parent 3c204ea commit 7ff165c

8 files changed

+142
-0
lines changed

traefik/VALUES.md

+5
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ Kubernetes: `>=1.22.0-0`
102102
| hub.redis.username | string | `""` | The username to use when connecting to Redis endpoints. Default: "". |
103103
| hub.sendlogs | string | `nil` | |
104104
| hub.token | string | `""` | Name of `Secret` with key 'token' set to a valid license token. It enables API Gateway. |
105+
| hub.tracing.additionalTraceHeaders | object | `{"enabled":false,"traceContext":{"parentId":"","traceId":"","traceParent":"","traceState":""}}` | Tracing headers to duplicate. To configure the following, tracing.otlp.enabled needs to be set to true. |
106+
| hub.tracing.additionalTraceHeaders.traceContext.parentId | string | `""` | Name of the header that will contain the parent-id header copy. |
107+
| hub.tracing.additionalTraceHeaders.traceContext.traceId | string | `""` | Name of the header that will contain the trace-id copy. |
108+
| hub.tracing.additionalTraceHeaders.traceContext.traceParent | string | `""` | Name of the header that will contain the traceparent copy. |
109+
| hub.tracing.additionalTraceHeaders.traceContext.traceState | string | `""` | Name of the header that will contain the tracestate copy. |
105110
| image.pullPolicy | string | `"IfNotPresent"` | Traefik image pull policy |
106111
| image.registry | string | `"docker.io"` | Traefik image host registry |
107112
| image.repository | string | `"traefik"` | Traefik image repository |

traefik/templates/_helpers.tpl

+2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ Key: {{ $cert.Key | b64enc }}
170170
{{- if kindIs "map" $value }}
171171
{{- include "traefik.yaml2CommandLineArgsRec" (dict "path" (printf "%s.%s" $path $key) "content" $value) -}}
172172
{{- else }}
173+
{{- with $value }}
173174
--{{ join "." (list $path $key)}}={{ join "," $value }}
175+
{{- end -}}
174176
{{- end -}}
175177
{{- end -}}
176178
{{- end -}}

traefik/templates/_podtemplate.tpl

+3
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,9 @@
812812
{{- with .sendlogs }}
813813
- "--hub.sendlogs={{ . }}"
814814
{{- end }}
815+
{{- if and $.Values.tracing.otlp.enabled .tracing.additionalTraceHeaders.enabled }}
816+
{{- include "traefik.yaml2CommandLineArgs" (dict "path" "hub.tracing.additionalTraceHeaders.traceContext" "content" $.Values.hub.tracing.additionalTraceHeaders.traceContext) | nindent 10 }}
817+
{{- end }}
815818
{{- end }}
816819
{{- end }}
817820
env:

traefik/templates/requirements.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,20 @@
4747
{{- if and (semverCompare "<v3.1.0-0" $version) .Values.tracing.safeQueryParams }}
4848
{{ fail "ERROR: safeQueryParams is a feature only available for traefik >= v3.1.0."}}
4949
{{- end }}
50+
51+
52+
{{- if $.Values.hub.token -}}
53+
{{ if not $.Values.image.tag }}
54+
{{ fail "When using Traefik Hub image tag needs to be specified !" }}
55+
{{- end -}}
56+
57+
{{ $hubVersion := (split "@" (default "v3" $.Values.image.tag))._0 | replace "latest-" "" }}
58+
59+
{{- if and (semverCompare "<v3.9.0" $hubVersion) .Values.hub.tracing.additionalTraceHeaders.enabled }}
60+
{{ fail "ERROR: additionalTraceHeaders is a feature only available for traefik-hub >= v3.9.0."}}
61+
{{- end }}
62+
63+
{{- if and (not $.Values.tracing.otlp.enabled) .Values.hub.tracing.additionalTraceHeaders.enabled }}
64+
{{ fail "ERROR: additionalTraceHeaders needs tracing.otlp to be enabled."}}
65+
{{- end }}
66+
{{- end }}

traefik/tests/requirements-config_test.yaml

+39
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ tests:
6565
- notFailedTemplate: {}
6666
- it: should fail when using traefik-hub API management with namespaced RBACs
6767
set:
68+
image:
69+
registry: "ghcr.io"
70+
repository: "traefik/traefik-hub"
71+
tag: "v3"
6872
hub:
6973
token: xxx
7074
apimanagement:
@@ -141,3 +145,38 @@ tests:
141145
asserts:
142146
- failedTemplate:
143147
errorMessage: "ERROR: safeQueryParams is a feature only available for traefik >= v3.1.0."
148+
- it: should fail when using Traefik Hub without image registry and repository specified.
149+
set:
150+
hub:
151+
token: "xxx"
152+
asserts:
153+
- failedTemplate:
154+
errorMessage: "When using Traefik Hub image tag needs to be specified !"
155+
- it: should fail when using hub.tracing.additionalTraceHeaders on Traefik Hub < 3.9.0
156+
set:
157+
image:
158+
registry: "ghcr.io"
159+
repository: "traefik/traefik-hub"
160+
tag: v3.8.0
161+
hub:
162+
token: "xxx"
163+
tracing:
164+
additionalTraceHeaders:
165+
enabled: true
166+
asserts:
167+
- failedTemplate:
168+
errorMessage: "ERROR: additionalTraceHeaders is a feature only available for traefik-hub >= v3.9.0."
169+
- it: should fail when using hub.tracing.additionalTraceHeaders without tracing.otlp enabled
170+
set:
171+
image:
172+
registry: "ghcr.io"
173+
repository: "traefik/traefik-hub"
174+
tag: v3.9.0
175+
hub:
176+
token: "xxx"
177+
tracing:
178+
additionalTraceHeaders:
179+
enabled: true
180+
asserts:
181+
- failedTemplate:
182+
errorMessage: "ERROR: additionalTraceHeaders needs tracing.otlp to be enabled."

traefik/tests/traefik-config_test.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -780,3 +780,35 @@ tests:
780780
asserts:
781781
- failedTemplate:
782782
errorMessage: "ERROR: allowACMEByPass has been introduced with Traefik v3.1.3+"
783+
- it: should be possible to configure Traefik Hub additionalTraceHeaders
784+
set:
785+
image:
786+
registry: "ghcr.io"
787+
repository: "traefik/traefik-hub"
788+
tag: v3.9.0
789+
tracing:
790+
otlp:
791+
enabled: true
792+
hub:
793+
token: "xxx"
794+
tracing:
795+
additionalTraceHeaders:
796+
enabled: true
797+
traceContext:
798+
parentId: "parentId"
799+
traceId: "traceId"
800+
traceParent: "traceParent"
801+
traceState: "traceState"
802+
asserts:
803+
- contains:
804+
path: spec.template.spec.containers[0].args
805+
content: "--hub.tracing.additionalTraceHeaders.traceContext.parentId=parentId"
806+
- contains:
807+
path: spec.template.spec.containers[0].args
808+
content: "--hub.tracing.additionalTraceHeaders.traceContext.traceId=traceId"
809+
- contains:
810+
path: spec.template.spec.containers[0].args
811+
content: "--hub.tracing.additionalTraceHeaders.traceContext.traceParent=traceParent"
812+
- contains:
813+
path: spec.template.spec.containers[0].args
814+
content: "--hub.tracing.additionalTraceHeaders.traceContext.traceState=traceState"

traefik/values.schema.json

+30
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,36 @@
358358
},
359359
"token": {
360360
"type": "string"
361+
},
362+
"tracing": {
363+
"properties": {
364+
"additionalTraceHeaders": {
365+
"properties": {
366+
"enabled": {
367+
"type": "boolean"
368+
},
369+
"traceContext": {
370+
"properties": {
371+
"parentId": {
372+
"type": "string"
373+
},
374+
"traceId": {
375+
"type": "string"
376+
},
377+
"traceParent": {
378+
"type": "string"
379+
},
380+
"traceState": {
381+
"type": "string"
382+
}
383+
},
384+
"type": "object"
385+
}
386+
},
387+
"type": "object"
388+
}
389+
},
390+
"type": "object"
361391
}
362392
},
363393
"type": "object"

traefik/values.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -979,3 +979,17 @@ hub:
979979
insecureSkipVerify: false
980980
# Enable export of errors logs to the platform. Default: true.
981981
sendlogs: # @schema type:[boolean, null]
982+
tracing:
983+
# -- Tracing headers to duplicate.
984+
# To configure the following, tracing.otlp.enabled needs to be set to true.
985+
additionalTraceHeaders:
986+
enabled: false
987+
traceContext:
988+
# -- Name of the header that will contain the parent-id header copy.
989+
parentId: ""
990+
# -- Name of the header that will contain the trace-id copy.
991+
traceId: ""
992+
# -- Name of the header that will contain the traceparent copy.
993+
traceParent: ""
994+
# -- Name of the header that will contain the tracestate copy.
995+
traceState: ""

0 commit comments

Comments
 (0)