Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions helm/kagent/templates/controller-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,30 @@ data:
OTEL_EXPORTER_OTLP_LOGS_TIMEOUT: {{ .Values.otel.logging.exporter.otlp.timeout | quote }}
{{- end }}
{{- end }}
{{- if .Values.otel.tracing.exporter.otlp.headers }}
{{- $traceHeaders := list }}
{{- range $k := keys .Values.otel.tracing.exporter.otlp.headers | sortAlpha }}
{{- $traceHeaders = append $traceHeaders (printf "%s=%s" $k (index $.Values.otel.tracing.exporter.otlp.headers $k | toString)) }}
{{- end }}
OTEL_EXPORTER_OTLP_TRACES_HEADERS: {{ join "," $traceHeaders | quote }}

@mesutoezdil mesutoezdil Jul 23, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heads up if a header val has a comma in it, it'll silently break bc theres no escaping b4 the join, might wanna add a check or just a note in the warning

{{- end }}
{{- if .Values.otel.logging.exporter.otlp.headers }}
{{- $logHeaders := list }}
{{- range $k := keys .Values.otel.logging.exporter.otlp.headers | sortAlpha }}
{{- $logHeaders = append $logHeaders (printf "%s=%s" $k (index $.Values.otel.logging.exporter.otlp.headers $k | toString)) }}
{{- end }}
OTEL_EXPORTER_OTLP_LOGS_HEADERS: {{ join "," $logHeaders | quote }}
{{- end }}
{{- if .Values.otel.serviceName }}
OTEL_SERVICE_NAME: {{ .Values.otel.serviceName | quote }}
{{- end }}
{{- if .Values.otel.resourceAttributes }}
{{- $resourceAttrs := list }}
{{- range $k := keys .Values.otel.resourceAttributes | sortAlpha }}
{{- $resourceAttrs = append $resourceAttrs (printf "%s=%s" $k (index $.Values.otel.resourceAttributes $k | toString)) }}
{{- end }}
OTEL_RESOURCE_ATTRIBUTES: {{ join "," $resourceAttrs | quote }}
{{- end }}
{{- if .Values.proxy.url }}
PROXY_URL: {{ .Values.proxy.url | quote }}
{{- end }}
Expand Down
57 changes: 57 additions & 0 deletions helm/kagent/tests/controller-deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,63 @@ tests:
path: data.A2A_BASE_URL
value: "https://kagent.example.com"

- it: should not set optional OTEL env vars by default
template: controller-configmap.yaml
asserts:
- notExists:
path: data.OTEL_SERVICE_NAME
- notExists:
path: data.OTEL_RESOURCE_ATTRIBUTES
- notExists:
path: data.OTEL_EXPORTER_OTLP_TRACES_HEADERS
- notExists:
path: data.OTEL_EXPORTER_OTLP_LOGS_HEADERS

- it: should set OTEL_SERVICE_NAME when configured
template: controller-configmap.yaml
set:
otel:
serviceName: "kagent-controller-prod"
asserts:
- equal:
path: data.OTEL_SERVICE_NAME
value: "kagent-controller-prod"

- it: should render OTEL_RESOURCE_ATTRIBUTES as sorted key=value pairs
template: controller-configmap.yaml
set:
otel:
resourceAttributes:
service.namespace: kagent
deployment.environment: production
asserts:
- equal:
path: data.OTEL_RESOURCE_ATTRIBUTES
value: "deployment.environment=production,service.namespace=kagent"

- it: should render OTLP traces and logs headers as sorted key=value pairs
template: controller-configmap.yaml
set:
otel:
tracing:
exporter:
otlp:
headers:
x-honeycomb-team: trace-key
x-honeycomb-dataset: kagent
logging:
exporter:
otlp:
headers:
authorization: "Basic bG9ncw=="
asserts:
- equal:
path: data.OTEL_EXPORTER_OTLP_TRACES_HEADERS
value: "x-honeycomb-dataset=kagent,x-honeycomb-team=trace-key"
- equal:
path: data.OTEL_EXPORTER_OTLP_LOGS_HEADERS
value: "authorization=Basic bG9ncw=="

- it: should set PROXY_URL when set
template: controller-configmap.yaml
set:
Expand Down
29 changes: 29 additions & 0 deletions helm/kagent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,19 @@ oauth2-proxy:
# ==============================================================================

otel:
# -- Logical service name reported to the OTLP backend, rendered as OTEL_SERVICE_NAME.
Comment thread
shekhargit1912 marked this conversation as resolved.
# WARNING: the controller copies every OTEL_ env var from its own process into
# every agent pod it creates (see collectOtelEnvFromProcess), so setting this
# also relabels the service name reported by every agent's telemetry, not just
# the controller's.
# @default -- "" (SDK default)
serviceName: ""
# -- Additional OpenTelemetry resource attributes, rendered as a comma-joined
# key=value list in OTEL_RESOURCE_ATTRIBUTES.
# WARNING: like serviceName, this is copied into every agent pod's environment
# as well as the controller's.
# Example: { deployment.environment: production, service.namespace: kagent }
resourceAttributes: {}
tracing:
enabled: false
exporter:
Expand All @@ -925,13 +938,29 @@ otel:
protocol: "grpc"
timeout: 15000 # milliseconds
insecure: true
# -- Headers sent with OTLP trace export requests, rendered as a comma-joined
# key=value list in OTEL_EXPORTER_OTLP_TRACES_HEADERS.
# WARNING: values land in the controller ConfigMap in plain text, AND the
# controller copies every OTEL_ env var into every agent pod it creates, so
# any secret set here (API keys, tokens) is exposed in plain text on every
# agent pod too, not just the controller. Prefer injecting such headers via
# controller.env / envFrom from a Secret instead.
headers: {}
logging:
enabled: false
exporter:
otlp:
endpoint: ""
timeout: 15000 # milliseconds
insecure: true
# -- Headers sent with OTLP log export requests, rendered as a comma-joined
# key=value list in OTEL_EXPORTER_OTLP_LOGS_HEADERS.
# WARNING: values land in the controller ConfigMap in plain text, AND the
# controller copies every OTEL_ env var into every agent pod it creates, so
# any secret set here (API keys, tokens) is exposed in plain text on every
# agent pod too, not just the controller. Prefer injecting such headers via
# controller.env / envFrom from a Secret instead.
headers: {}

# ==============================================================================
# EXTRA OBJECTS
Expand Down
Loading