feat(helm): expose OTEL headers, service name, and resource attributes#2272
feat(helm): expose OTEL headers, service name, and resource attributes#2272shekhargit1912 wants to merge 4 commits into
Conversation
The controller already honors the standard OpenTelemetry SDK env vars, but the chart had no way to set them, leaving authenticated OTLP backends (Langfuse Cloud, Honeycomb, Datadog, Grafana Cloud, New Relic) unreachable without post-render hacks. Add optional values, all rendered into the controller ConfigMap only when set so existing installs render identically: - otel.tracing.exporter.otlp.headers -> OTEL_EXPORTER_OTLP_TRACES_HEADERS - otel.logging.exporter.otlp.headers -> OTEL_EXPORTER_OTLP_LOGS_HEADERS - otel.serviceName -> OTEL_SERVICE_NAME - otel.resourceAttributes -> OTEL_RESOURCE_ATTRIBUTES Header and attribute maps render as comma-joined key=value pairs with sorted keys, matching the DEFAULT_AGENT_POD_LABELS pattern. Secret header values should instead be injected via controller.env/envFrom, as documented in values.yaml. Fixes kagent-dev#2126 Signed-off-by: shekhargit1912 <shekharchaugule302@gmail.com>
Signed-off-by: Shekhar Chaugule <79699567+shekhargit1912@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR enhances the helm/kagent chart to expose additional standard OpenTelemetry SDK environment variables (service name, resource attributes, and OTLP headers) via values.yaml, rendering them into the controller ConfigMap only when configured to preserve backwards-compatible output.
Changes:
- Added
otel.serviceNameandotel.resourceAttributesvalues, mapping toOTEL_SERVICE_NAMEandOTEL_RESOURCE_ATTRIBUTES. - Added
otel.tracing.exporter.otlp.headersandotel.logging.exporter.otlp.headers, mapping toOTEL_EXPORTER_OTLP_TRACES_HEADERSandOTEL_EXPORTER_OTLP_LOGS_HEADERS, serialized as sortedk=vpairs. - Added Helm chart tests to validate absence-by-default and deterministic sorted rendering when set.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| helm/kagent/values.yaml | Adds new OTEL-related values with guidance about avoiding plaintext secrets in ConfigMaps. |
| helm/kagent/templates/controller-configmap.yaml | Conditionally renders the new OTEL env vars into the controller ConfigMap using sorted k=v serialization. |
| helm/kagent/tests/controller-deployment_test.yaml | Adds assertions covering default non-rendering and correct sorted rendering of the new fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
collectOtelEnvFromProcess() copies every OTEL_ env var from the controller's own process into every agent pod it creates, so otel.serviceName / otel.resourceAttributes relabel agent telemetry too, and OTLP header secrets set here land in plain text on every agent pod, not just the controller. Addresses review feedback from @mesutoezdil on kagent-dev#2272. Signed-off-by: shekhargit1912 <shekharchaugule302@gmail.com>
…elm-otel-values # Conflicts: # helm/kagent/values.yaml
|
@mesutoezdil Good catch - thanks. I confirmed it in collectOtelEnvFromProcess() / collectSharedEnv() and added warning comments to serviceName, resourceAttributes, and both headers fields. While checking I noticed it's actually broader than service-name relabeling: any secret set via headers would also get copied into every agent pod's env, not just the controller's, so I called that out too. Pushed in latest commit. |
|
HI @mesutoezdil could you please check this .? |
| {{- 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 }} |
There was a problem hiding this comment.
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
The controller already honors the standard OpenTelemetry SDK env vars, but the chart had no way to set them, leaving authenticated OTLP backends (Langfuse Cloud, Honeycomb, Datadog, Grafana Cloud, New Relic) unreachable without post-render hacks.
Add optional values, all rendered into the controller ConfigMap only when set so existing installs render identically:
Header and attribute maps render as comma-joined key=value pairs with sorted keys, matching the DEFAULT_AGENT_POD_LABELS pattern. Secret header values should instead be injected via controller.env/envFrom, as documented in values.yaml.
Fixes #2126